0

I currently have a ViewPager with 3 completely static and different fragments. When my data loads I want it to fill certain EditTexts with data retrieved from the database. So far the only way I have been able to accomplish this is by doing an OnFocusChangeListener that called methods from the FragmentActivity to retrieve the data once saved locally and then displayed it. However, I know that is not a good way to do this at all.

Once my data is retrieved from the database it is stored locally in an Object. I simply want to be able to use setText to add the data to the EditText.

I don't need the code written for me, but I am looking for any sort of direction as all of my previous attempts have failed miserably at figuring this out.

I have attached my Fragment Adapter below. Each fragment is a completely different layout. If you need additional code I will post as needed.

ViewPager:

public class WellAdapter extends FragmentPagerAdapter {

    public WellAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        Fragment f;

        switch (position) {
        case 0:
            f = new Well8_1();
            break;
        case 1:
            f = new Well8_2();
            break;
        case 2:
            f = new Well8_3();
            break;
        default:
            f = new Fragment();
            break;
        }

        return f;
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        switch (position) {
        case 0:
            return getString(R.string.strRawWater);
        case 1:
            return getString(R.string.strChemicalsApplied);
        case 2:
            return getString(R.string.strChemicalTests);
        default:
            return "Page " + (position + 1);
        }
    }
}
Jim
  • 271
  • 6
  • 20
  • 1
    I've closed your question as a duplicate to the linked question. I'm assuming your problem is to access the content of a fragment which you can do with the code from the other question. Leave a comment if your question is about something else. – user May 28 '14 at 19:08
  • It seems like that might help, I guess my issue is that I'm struggling to understand the issues I'm having and how to implement the fix, and at the same time understand the implementation. A lot of the code examples I've seen seem to use completely different structures than my fragment manager uses. While that is essentially the same issue, I'm not sure if the fix is compatible with my current structure. – Jim May 29 '14 at 15:37

0 Answers0