如何在PreferenceActivity中的首选项右侧标记图标?

时间:2011-05-05 03:20:03

标签: android preferenceactivity preference

请点击查看图片 http://i1094.photobucket.com/albums/i455/tdounnyy/device.png

在此PreferenceActivity的底部,“选择铃声”右侧有一个图标/按钮。

而“振动”则没有。

此振动偏好是一个客户偏好扩展偏好。

我想在Vibrate行中放置相同的Icon。 一种方法是扩展ListPreference或RingtonePreference以欺骗操作系统。

我不喜欢这样,想知道是否有更好的解决方案。 ^ _ ^

preferences.xml感谢@Femi          

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- Layout used by PreferenceScreen. This is inflated inside 
        android.R.layout.preference. -->
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginRight="4dip"
    android:layout_gravity="center_vertical"
    android:background="@drawable/btn_circle"
    android:src="@drawable/ic_btn_round_more" />

我将前缀“android”添加为:

android:background="@android:drawable/btn_circle"
android:src="@android:drawable/ic_btn_round_more" />

现在,Eclipse说:错误:资源不公开。 我用Google搜索但没有运气。 有人想过如何突破?

1 个答案:

答案 0 :(得分:5)

创建首选项xml文件时,可以为首选项指定自定义布局,并可以在其中放置一个图标。最简单的方法是查看Android SDK文件夹:platforms / data // res / layout /(我相信它)包含用于不同首选项类型的实际布局文件:您可以从其中复制其中一个在那里,并使用它作为您自己的自定义偏好的基础。