我有一个复选框的列表视图,由休闲创建。
public void addCard(final String cardId){
ListView listView1;
Lists movielist = new Lists();
List<String> movies = new ArrayList<String>();
movies = movielist.movieList();
listView1 = (ListView)findViewById(R.id.listView1);
listView1.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, movies));
listView1.setItemsCanFocus(false);
listView1.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listView1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
CheckedTextView ctv = (CheckedTextView)arg1;
Toast.makeText(getApplicationContext(),ctv.getText().toString(), Toast.LENGTH_SHORT).show();
//do your stuff in here!
}
});
Button submit = (Button)findViewById(R.id.button1);
submit.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"", Toast.LENGTH_SHORT).show();
}
});
}
现在,当一个框被选中时,我可以祝酒与复选框相关联的文本。我希望能够做的是烤与单击提交时选中的所有框相关联的文本。
理想情况下,我想要一个列表,其中每个值都是与复选框关联的文本块之一。
干杯!