2011-11-22 71 views

回答

1

你可能想要的是保存您的活動狀態,而不是onSaveInstanceState,像這樣:

@Override 
protected void onSaveInstanceState(Bundle outState) { 
    super.onSaveInstanceState(outState); 
    outState.putString(MY_KEY, myStringValue); 
    // ... 
} 

然後在的onCreate:

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    // other stuff... 

    if(savedInstanceState != null) { 
     myStringValue = savedInstanceState.getString(MY_KEY); 
    } 

} 
+0

@my機器人:您可能也想了解一下[ TabHost.OnTabChangeListener](http://stackoverflow.com/q/2243360/593709) –

+0

onTabChangeListner將僅在Activity A中調用,但我想保存活動B和C的字段值,那麼我將如何保存B的字段值C調用A方法 –