这里的例子使用单选列表视图给你:
主.xml:
<?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/listview1"
android:cacheColorHint="#00000000"
android:scrollbars="none"
android:fadingEdge="vertical"
android:soundEffectsEnabled="true"
android:dividerHeight="1px"
android:padding="5dip"
android:smoothScrollbar="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginBottom="10dip"
android:layout_weight="1"/>
</LinearLayout>
活动:
String[] items = new String[] { "Item1", "Item2", "Item3", "Item4" };
int[] itemsIds = new int[] { 8, 14, 30, 42 };
ListView listView = (ListView)findViewById(R.id.listview1);
listView.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_single_choice, android.R.id.text1, items));
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
//here send your item id itemsIds[position]
}
});