這是我在SingleChoiceDialog使用
1.select_dialog_singlechoice.xml
<?xml version="1.0" encoding="UTF-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="@style/PopupSelectList"
android:checkMark="@drawable/radio"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:paddingLeft="12.0dip"
android:paddingRight="10.0dip" />
2.style.xml
<style name="PopupSelectList">
<item name="android:textSize">16.0sp</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@drawable/list_item_selector</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:minHeight">@dimen/dialog_select_height</item>
</style>
3.ratio.xml
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dot_selected" android:state_checked="true" android:state_window_focused="false"/>
<item android:drawable="@drawable/dot_normal" android:state_checked="false" android:state_window_focused="false"/>
<item android:drawable="@drawable/dot_normal" android:state_checked="false"/>
<item android:drawable="@drawable/dot_selected" android:state_checked="true"/>
</selector>
4.在Adapter的g etView
CheckedTextView title = (CheckedTextView) convertView
.findViewById(android.R.id.text1);
title.setText(mItems[position]);
title.setSelected(mCheckedItem == position ? true : false);
title.setCheckMarkDrawable(position == mCheckedItem ? R.drawable.dot_selected
: R.drawable.dot_normal);
然後CheckedTextView應該被命名爲ListCheckedTextView?該死的谷歌 – 2016-08-27 23:24:41