I have been trying to set a new xml layout, when a particular item on this list is clicked. Am I missing something, because the emulator crashes when clicked?! setContentViewById(R.id.newxml file)
public class intentProject extends ListActivity
{
ListView list;
ArrayAdapter<String> aa;
List<String> data = new ArrayList<String>();
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(sa开发者_StackOverflow中文版vedInstanceState);
setContentView(R.layout.main);
data.add("France");
data.add("Japan");
data.add("Russia ");
data.add("Poland");
data.add(" USA");
ArrayAdapter<String> aa = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,data
);
setListAdapter(aa);
}
protected void onListItemClick(ListView l, View v, int position, long id)
{
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
this.setContentView(R.layout.main2);
}
}
No I am not using a listview in the next xml. It is going to be a plain xml file with 2 buttons. These buttons are going to implement intents.
精彩评论