Android Studio中呈现的问题:首
问题描述:
这里是我的preferences.xml文件的代码:Android Studio中呈现的问题:首
<?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>
机器人工作室渲染器给了我以下错误信息:
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)不说了关于这个的话。 (当运行代码时,它们显示一个操作栏,我只能看到屏幕最上方的复选框偏好)
答
PreferenceFragment
的接口不能被定义为布局资源文件,而应该被定义为XML资源文件。这是在你给的链接中解释,但以某种方式隐藏:http://developer.android.com/guide/topics/ui/settings.html#Fragment
如果你遵循这种方法,Android Studio的渲染工作正常。