开发者

ListView onListItemClick setcontentview crash?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜