【问题标题】:Android Studio rendering problems: PreferencesAndroid Studio 渲染问题:首选项
【发布时间】:2015-04-01 23:25:01
【问题描述】:

这是我的preferences.xml文件的代码:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
    <CheckBoxPreference
        android:key = "test"
        android:title = "Test"
        android:summary = "Yes It WORKED"
        android:defaultValue="true"
        />

</PreferenceScreen>

android studios 渲染器给我以下错误信息:

The following classes could not be found:
    -CheckBoxPreference(Fix build path)
    -PreferenceScreen(Fix build path)

当我没有输入时它也给了我错误:

android:layout_height="match_parent"
android:layout_width="match_parent">

尽管 Google 本身 (http://developer.android.com/guide/topics/ui/settings.html) 对此一言不发。 (他们在运行代码时会显示一个操作栏,我得到的只是屏幕顶部的复选框首选项)

【问题讨论】:

    标签: android xml android-studio rendering


    【解决方案1】:

    在 res 中创建一个 xml 文件夹并将您的 .xml 文件(例如:preferences.xml)移动到其中。

    【讨论】:

      【解决方案2】:

      PreferenceFragment 的接口不能定义为布局资源文件,而应定义为 XML 资源文件。这在您提供的链接中进行了解释,但不知何故被隐藏了:http://developer.android.com/guide/topics/ui/settings.html#Fragment

      如果你遵循这种方法,Android Studio 的渲染效果很好。

      【讨论】:

        猜你喜欢
        • 2013-08-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-21
        • 2014-10-13
        • 2015-09-14
        • 1970-01-01
        相关资源
        最近更新 更多