خوب ببین داخل onCreate و اینا که نمیتونی اور رایدش کنی عزیزم. یه مثال میزنم برات. این مثال وضعیت رو زمان چرخودن گوشی نگهداری میکنه:
public class MainActivity extends Activity
{
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
System.out.println("TAG, onSavedInstanceState");
final TextView text = (TextView)findViewById(R.id.textView1);
CharSequence userText = text.getText();
outState.putCharSequence("savedText", userText);
}
protected void onRestoreInstanceState(Bundle savedState)
{
System.out.println("TAG, onRestoreInstanceState");
final TextView text = (TextView)findViewById(R.id.textView1);
CharSequence userText = savedState.getCharSequence("savedText");
text.setText(userText);
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final String name = "5";
final TextView show = (TextView)findViewById(R.id.textView1);
Button btn = (Button)findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
// TODO Auto-generated method stub
show.setText(name);
}
});
}
}