In android listview we can able to select more then one option at a time in list.
Here is a simple example for how to select more then one option from list.
Multiple Choice ListView Example :-
****************************************
xml file
xml version = "1.0" encoding = "utf-8" ?>
|
2 | < LinearLayout android:id = "@+id/LinearLayout01" |
3 | android:layout_width = "fill_parent" android:layout_height = "fill_parent" |
5 | < ListView android:id = "@+id/ListView01" android:layout_height = "wrap_content" |
6 | android:layout_width = "fill_parent" > ListView > |
******************************
Java file
public class ListViewMultipleChoiceExample extends Activity { |
02 | private ListView lView; |
03 | private String lv_items[] = { "Android" , "iPhone" , "BlackBerry" , |
04 | "AndroidPeople" , "J2ME" , "Listview" , "ArrayAdapter" , "ListItem" , |
05 | "Us" , "UK" , "India" }; |
08 | public void onCreate(Bundle icicle) { |
09 | super .onCreate(icicle); |
10 | setContentView(R.layout.main); |
11 | lView = (ListView) findViewById(R.id.ListView01); |
13 | lView.setAdapter( new ArrayAdapter( this , |
14 | android.R.layout.simple_list_item_multiple_choice, lv_items)); |
15 | lView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); |
******************************
output :
how to select all item on one button click event
ReplyDelete