2

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

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

而“振动”则不会。

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

我想在振动行中放置相同的图标。一种方法是将 ListPreference 或 RingtonePreference 扩展到欺骗操作系统。

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

首选项.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2006 The Android Open Source Project

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 说:错误:资源不公开。我用谷歌搜索但没有运气。有想过怎么突破吗?

4

1 回答 1

7

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

于 2011-05-05T04:10:32.903 回答