开发者

ListView onListItemClick setcontentview crash?

开发者 https://www.devze.com 2023-01-23 10:28 出处:网络
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)

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号