如何用List Preference Android中的图像替换单选按钮

时间:2014-06-11 08:24:56

标签: android listpreference

我有以下偏好列表。

    <ListPreference
        android:key="@string/settings_key_keyboard_theme_key"           
        android:title="@string/select_skin"
        android:entries="@array/select_keyboard_skin"
        android:entryValues="@array/the_value_of_keyboard_skin"
        android:dialogTitle="@string/select_skin"
        android:defaultValue="@string/settings_default_keyboard_theme_key" />

  <string-array name="select_keyboard_skin">        
    <item>White</item>
    <item>Black</item>
    <item>Wood</item>        
    <item>Beige</item>
    <item>Leather</item>
    <item>Purple</item>
    <item>Blackberry</item>
   </string-array>

我想用图片图标替换某些项目的单选按钮。例如,它可能是这样的:

If(Item == White || Black || Wood){
(RadioButton).SetVisbility(Invisible)
(ImageButton).SetVisibility(Visible)
}

我是List Preference Activity的新手。请提一些建议吗?

1 个答案:

答案 0 :(得分:1)

您必须延长ListPreference并覆盖onPrepareDialogBuilder(Builder)OnCreateDialogView() 看到这个:Ho to customize list preference radio button