Wednesday, 23 November 2011

ListView Multiple Choice

main.xml



<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/Layout1"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView android:id="@+id/ListView1" android:layout_height="wrap_content"
android:layout_width="fill_parent"></ListView>
</LinearLayout>


ListViewMultipleChoice.java


 public class ListViewMultipleChoice extends Activity {
private ListView list;
private String lv_items[] = { "Android", "iPhone", "BlackBerry"};

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);

setContentView(R.layout.main);

list = (ListView) findViewById(R.id.ListView1);

list.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice, lv_items));
list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
}







No comments:

Post a Comment