android 关于listview的问题
publicclassMyActivityextendsActivity{/***Calledwhentheactivityisfirstcreated.*/@Overr...
public class MyActivity extends Activity {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setList();
}
public void setList(){
ListView mainList = (ListView)findViewById(R.id.listView01);
String[] arrList = {"孙悟空","猪八戒","牛魔王"};
ArrayAdapter<String> adapterList = new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_2,arrList);
mainList.setAdapter(adapterList);
}
}
只要添加上setList这个函数,程序运行时就提示停止退出,去掉这个函数就没问题,不知道哪里出错了,敬候大神指导! 展开
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setList();
}
public void setList(){
ListView mainList = (ListView)findViewById(R.id.listView01);
String[] arrList = {"孙悟空","猪八戒","牛魔王"};
ArrayAdapter<String> adapterList = new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_2,arrList);
mainList.setAdapter(adapterList);
}
}
只要添加上setList这个函数,程序运行时就提示停止退出,去掉这个函数就没问题,不知道哪里出错了,敬候大神指导! 展开
1个回答
展开全部
可以查看这个博客,你就知道错哪里了。
http://blog.csdn.net/kaypro/article/details/15334703
http://blog.csdn.net/kaypro/article/details/15334703
追问
还是一样的结果,我全复制过去都不行,还是出错
追答
我直接把那个博客的源码发给你研究研究。。。或者你把错误贴出来我看看
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询