Tuesday, February 28, 2012

Change Activity layout


In my app i want to change the Activity contentview if a button was clicked for example.



In the begining i call the first layou:




public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.catalog);
}



and when a button was pressed i call this one:




public void showItemActivity(int position){
setContentView(R.layout.item_view);
}



and in this method my app crash.



i need to say that if i try this method:




setContentView(R.layout.item_view);



in the begin of another Activity it work perfectly, but it reali important for me that it will be in the same Activity .



Edit



the logchat error msg:




java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

No comments:

Post a Comment