Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 更改特定首选项的背景无效_Android_Android View_Android Preferences_Android Viewgroup - Fatal编程技术网

Android 更改特定首选项的背景无效

Android 更改特定首选项的背景无效,android,android-view,android-preferences,android-viewgroup,Android,Android View,Android Preferences,Android Viewgroup,我有一个首选项,用作应用程序的设置。我想更改listpref(listview)中特定项目的背景色。我使用了下面的代码: Drawable background = getResources().getDrawable(R.drawable.bg_barcode_des); addPreferencesFromResource(R.xml.admin_preferences); Preference credentials = findPreference("demo")

我有一个首选项,用作应用程序的设置。我想更改listpref(listview)中特定项目的背景色。我使用了下面的代码:

    Drawable background = getResources().getDrawable(R.drawable.bg_barcode_des);
    addPreferencesFromResource(R.xml.admin_preferences);
    Preference credentials = findPreference("demo");
    View credentialsView = credentials.getView(null, null);
    credentialsView.setBackgroundDrawable(background);

    //**OR** credentialsView.setBackground(background);
    //**OR** credentialsView.setBackgroundColor(Color.RED);
    //Non of these or working...
但我的偏好活动没有改变。我需要做什么修正