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'
The problem is that your activity class may have extended ListActivity, and you should have a ListView whose id attribute is
android.R.id.listin your layout xml file, so that your ListActivty class can find the main list of this activity.(if someClass extends ListActivity, it means that someClass, mainly has the role of a list). Just set your ListView id toandroid.R.id.listinlayout/item_view.xml.