FragmentPagerSupport is a FragmentActivity class, FragmentA and FragmentB are representing 2 different tabs. In the First tab I have a EditText and a button. My task is to on button click need to open the 2nd tab and show the EditText value in the 2nd tab. I am also using a FragmentStatePagerAdapter.
Following code is building tabs onCreate() of FragmentActivity:
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
actionBar.addTab(actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}
My code in FragmentStatePagerAdapter is as follow:
public Fragment getItem(int position) {
Fragment fragment = null;
Bundle args = new Bundle();
switch (position) {
case 0:
fragment = FragmentA();
args.putInt(FragmentA.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
break;
case 1:
fragment = new FragmentB();
args.putInt(FragmentB.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
break;
}
return fragment;
}
My code of FragmentA on button click is as follow:
confirmButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
}
}
Now I stuck here. Can't find what should be the code here to call the 2nd tab and show the value according to tab1 EditText value.