您的位置:首页 > 其它

ListView实现单选(一)

2015-12-13 19:59 393 查看
1 在ListView中添加
android:choiceMode="singleChoice"

如下:
<ListView
android:id="@+id/list_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
>

</ListView>

2 在适配器中填充布局的时候填充

android.R.layout.simple_list_item_single_choice
返回为CheckedTextView
如下:
CheckedTextView view = (CheckedTextView) (convertView == null ?
LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_single_choice, parent, false) : convertView);
然后将view当成RadioButton来用即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: