0

我是 android 的新手,我想在我的布局和代码中显示一个列表视图但它会抛出致命错误请建议我

活动代码:

String [] frnds = {"Ajay Kumar", "Atul kumar", "Deepak Arora", "Mamta kri", "Mimi"};
ListView frndlist;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
    //setListAdapter(new ArrayAdapter<String>(MainActivity.this,android.R.layout.simple_list_item_1, frnds));

    setContentView(R.layout.activity_main);
    frndlist = (ListView)findViewById(R.id.listView1);
    frndlist.setAdapter( new ArrayAdapter(MainActivity.this,android.R.layout.simple_list_item_1 ,frnds));

}
4

1 回答 1

0

我认为您错过了一些东西,请将您的代码更改为以下内容:

frndlist.setAdapter( new ArrayAdapter<String>(MainActivity.this,android.R.layout.simple_list_item_1 ,frnds));
于 2013-09-01T18:28:57.713 回答