Skip to main content

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'




Comments

Popular posts from this blog

Wildcards in a hosts file

I want to setup my local development machine so that any requests for *.local are redirected to localhost . The idea is that as I develop multiple sites, I can just add vhosts to Apache called site1.local , site2.local etc, and have them all resolve to localhost , while Apache serves a different site accordingly.