I'm making a program that when I press a button this change the background color but I have a problem with, when I change the screen orientation this change again the color to the predefined and I dont know how to solve this problem... Here is my code.
public class MainActivity extends Activity implements OnClickListener {
LinearLayout myLayout;
LinearLayout myLayout2;
// Declare UI elements
private Button firstButton, secondButton, thirdButton, fourthButton, fifthButton;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); // Our only layout for this app is main.xml
myLayout = (LinearLayout) findViewById(R.id.myLayout);
myLayout2 = (LinearLayout) findViewById(R.id.myLayout2);
// Initialize the UI components
firstButton = (Button) findViewById(R.id.button1);
// When we creating a button and if we expect that to use for event handling we have to set the listener
firstButton.setOnClickListener(this);
secondButton = (Button) findViewById(R.id.button2);
secondButton.setOnClickListener(this);
thirdButton = (Button) findViewById(R.id.button3);
thirdButton.setOnClickListener(this);
fourthButton = (Button) findViewById(R.id.button4);
fourthButton.setOnClickListener(this);
fifthButton = (Button) findViewById(R.id.button5);
fifthButton.setOnClickListener(this);
}
}