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);
}
}
}