Reputation: 1296
I have a tabHost in a TabActivity, it contains 3 Tabs, and each one of theese tab has it's own class, i can navigate between the different Tabs using an Intent, Once i change the orientation of my phone, or when i change the current tab to another, i lost all the data(ImageView, text on my editTexts) in the previous Tab.
Updated:
I tried the onSavedInstanceState method, but nothing changed:
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.vendre);
imageView = (ImageView) findViewById(R.id.SelectedImage);
if(savedInstanceState!=null)
{
imageView.setImageBitmap((Bitmap) savedInstanceState.getParcelable("image"));
((EditText)findViewById(R.id.VendreName)).setText(savedInstanceState.getString("nomProduit"));
((EditText)findViewById(R.id.VendreDescription)).setText(savedInstanceState.getString("description"));
((EditText)findViewById(R.id.VendrePrix)).setText(savedInstanceState.getString("prix"));
}
}
@Override
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
outState.putString("nomProduit", ((TextView)findViewById(R.id.VendreName)).getText().toString());
outState.putString("description", ((TextView)findViewById(R.id.VendreDescription)).getText().toString());
outState.putString("prix", ((TextView)findViewById(R.id.VendrePrix)).getText().toString());
Bitmap b= ((BitmapDrawable)imageView.getDrawable()).getBitmap();
outState.putParcelable("image",b);
}
It seems that this method is never called.
Upvotes: 1
Views: 124
Reputation: 2528
Add android:configChanges="orientation|screenSize" line in AndroidManifest.xml for your activity. It is not a good solution.
Upvotes: 1