I have an app with a main view and a set of sub-views, defined as XMLs. I load the main view with:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
When I switch to another view I do:
holaPlayerBtn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View view)
{
setContentView(R.layout.primerareceta);
};
To go back to the main view I am trying:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event){
if (keyCode == KeyEvent.KEYCODE_BACK){
setContentView(R.layout.main);
return true;
}
return super.onKeyDown(keyCode, event);
}
But doing this, what I get is the main view repainted, but the buttons that it contains are not functioning any longer.
Do you know why is happening this? How can I go back to the main view with all its button functioning as in the previous time?
Thanks for your help Pedro