ListView中自带选择模式,这里是要实现单选,所以设置listview属性为singlechoice,为单选模式,Listview布局如下:
<ListView android:id="@+id/lv_main" android:layout_width="match_parent" android:layout_height="wrap_content" android:choiceMode="singleChoice" android:dividerHeight="1dp" android:divider="#e1e1e1"/>item的布局如下,就一个TextView加上一个RadioButton
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" android:padding="20dp" android:gravity="center_vertical"> <TextView android:id="@+id/tv_item" android:layout_width="wrap_content"