Hi! so im currently having a problem regarding the onSaveInstaceState
method in the Fragment class. This class is called from a FragmentActivity
that acts as a Tab created in another FragmentActivity, but i cant seem to
make the call to onSaveInstanceState to happen, here's some code:
*mainmenu *class that generates the tabs:
public class MainMenu extends FragmentActivity{
>
>
>> private TabHost tabs=null;
>
>
>> public String getWindowTitle() {
>
> return "Home";
>
> }
>
>
>> //@Override
>
> public int getLayoutId() {
>
> return R.layout.main_menu;
>
> }
>
>
>> //@Override
>
> public int getThemeId() {
>
> return R.style.CustomTheme;
>
> }
>
>
>> @Override
>
> public void onSaveInstanceState(Bundle bundle) {
>
>
>> super.onSaveInstanceState(bundle);
>
> bundle.putInt("TAB",tabs.getCurrentTab());
>
> }
>
>
>> @Override
>
> public void onRestoreInstanceState(Bundle bundle) {
>
>
>> super.onRestoreInstanceState(bundle);
>
> tabs.setCurrentTab(bundle.getInt("TAB"));
>
>
>>
>> }
>
>
>> @Override
>
> public void onCreate(Bundle savedInstanceState) {
>
>
>> setTheme(getThemeId());
>
> super.onCreate(savedInstanceState);
>
> setContentView(getLayoutId());
>
> LocalActivityManager mlam = new LocalActivityManager(this, false);
>
> tabs=(TabHost)findViewById(android.R.id.tabhost);
>
> mlam.dispatchCreate(savedInstanceState);
>
> tabs.setup(mlam);
>
>
>> TabHost.TabSpec spec;
>
> Intent intent;
>
>
>> // Create an Intent to launch an Activity for the tab (to be reused)
>
> intent = new Intent().setClass(this, MyProcessListFragmentActivity.class);
>
> spec = tabs.newTabSpec("Home").setIndicator((buildTabIndicator("Home")))
>
> .setContent(intent);
>
> tabs.addTab(spec);
>
>
>> // Create an Intent to launch an Activity for the tab (to be reused)
>
> intent = new Intent().setClass(this, SearchProcess.class);
>
> spec =
>> tabs.newTabSpec("Search").setIndicator((buildTabIndicator("Search")))
>
> .setContent(intent);
>
>
>> // Create an Intent to launch an Activity for the tab (to be reused)
>
> intent = new Intent().setClass(this, MyProcessList.class);
>
> tabs.addTab(spec);
>
> spec =
>> tabs.newTabSpec("Options").setIndicator((buildTabIndicator("Options")))
>
> .setContent(intent);
>
>
>> tabs.addTab(spec);
>
>
>> tabs.setCurrentTab(0);
>
>
>>
>> }
>
>
Here's the *MyprocessListGragmentActivity*:
public class MyProcessListFragmentActivity extends FragmentActivity
> implements MyProcessFragmentList.onProcessSelectedListener{
>
> @Override
> protected void onCreate(Bundle arg0) {
> super.onCreate(arg0);
>
> setContentView(R.layout.myprocesslist_fragment);
> }
> }
>
and the Fragment class *MyProcessFragmentList *called from the layout :
public class MyProcessFragmentList extends IpdmsCoreFragment {
>
>
>> onProcessSelectedListener mListener;
>
>
>> private PullToRefreshListView mPullRefreshListView;
>
>
>> private LinkedList<GenericMenuItemListDTO> iTems;
>
> private List<MyProcessDTO> tempList;
>
> private GenericMenuAdapter adapter;
>
>
>> private int processListPage=1;
>
>
>>
>> // Container Activity must implement this interface
>
> public interface onProcessSelectedListener{
>
>
>> public void onArticleSelected(MyProcessDTO process);
>
> }
>
>
>>
>> @Override
>
> public void onAttach(Activity activity) {
>
> super.onAttach(activity);
>
>
>> try{
>
> mListener=(onProcessSelectedListener) activity;
>
> }catch(ClassCastException e){
>
> throw new ClassCastException(activity.toString() + " must implement
>> onProcessSelectedListener");
>
> }
>
> }
>
>
>>
>>
>> @Override
>
> public void onSaveInstanceState(Bundle outState) {
>
> super.onSaveInstanceState(outState);
>
>
>> outState.putSerializable("LISTPROCESS", adapter.getAllItems());
>
> }
>
>
The onSaveInstanceState never gets called on rotation....but if i run the
Fragment Activity directly it works and it gets called....
Regards,
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en