我不知道在下面的代码中我出错了。 我想创建一个包含多个项目选择的Listview 代码是:
email_arraylist= new ArrayList<String>();
for(int i =0; i < email_count; i++){
String next_mail = sp.getString("email"+i, null);
Toast.makeText(getBaseContext(), next_mail, Toast.LENGTH_LONG).show();
email_arraylist.add(next_mail);
}
Toast.makeText(getBaseContext(), "arraylist length is "+ email_arraylist.size(),Toast.LENGTH_LONG).show();
email_listview =new ListView(this);
email = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice,email_arraylist);
email_listview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
email_listview.setAdapter(email);
parentLayout.addView(email_listview,parentLayout.getChildCount()-1);
Toast消息根据存在的项目数显示正确的消息。但是我的Listview只会填充一个项目而不管出现的项目数量
任何人都可以找到错误并告诉我哪里出错了