In my case, i have used the FragmentActivity and contain two page of fragment. initialize by this way.
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a DummySectionFragment (defined as a static inner class
// below) with the page number as its lone argument.
switch (position) {
case 0:
return new Fragment1();
case 1:
return new Fragment2();
}
return null;
}
The action bar item is defined as below:
<item
android:id="@+id/item_edit"
android:icon="@android:drawable/ic_menu_edit"
android:showAsAction="ifRoom"
android:title="Edit"/>
<item
android:id="@+id/item_save"
android:icon="@android:drawable/ic_menu_save"
android:showAsAction="withText|always"
android:title="Save"/>
for example: i have one edittext at Fragment 1 and one edittext from Fragment 2.
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/editText2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
and then the problem is how can i get the edittext data from the two fragment when i click the save action bar item. Thank you so much.