You can use listview to implement a multi-choice list box.
Layout File
<? XML version = "1.0" encoding = "UTF-8"?> <Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Orientation = "vertical" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"> <listview Android: id = "@ + ID/Android: List" Android: layout_width = "match_parent" Android: layout_height = "match_parent" Android: Background = "# 0000ff" Android: layout_weight = "1" Android: drawselectid Top = "false"/> </linearlayout>
Class directly inherits the listactivity. When constructing a style, use simple_list_item_multiple_choice and set the selection method to choice_mode_multiple using setchoicemode.
public class listactivitytest extends listactivity {@ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); string [] arr = {"your story my song", "Hey Jude", "the moment "}; arrayadapter
adapter = new arrayadapter
(this, android. r. layout. simple_list_item_multiple_choice, arr); // set the display list of setlistadapter (adapter); Final listview = getlistview (); // listview. setitemscanfocus (false); listview. setchoicemode (listview. choice_mode_multiple) ;}}