2012-07-18 71 views
2

我有一個簡單的preferences.xml:PreferenceScreen類未找到

<?xml version="1.0" encoding="utf-8"?> 
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 
     <PreferenceCategory 
       android:title="First Category"> 
       <CheckBoxPreference 
.... 

我的Android版本是2.1(API7)的Java 1.6,使用日食靛藍。 在包資源管理器中有android.jar後我打開它有android.preference包。

即使這樣,我得到以下錯誤:

com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup 
Exception details are logged in Window > Show View > Error Log 
The following classes could not be found: 
- PreferenceCategory (Fix Build Path, Edit XML) 
- PreferenceScreen (Fix Build Path, Edit XML) 

我該怎麼辦? Thanx提前

+0

** res **中的哪個文件夾是否放置了您的* preferences.xml *文件? – waqaslam 2012-07-18 11:07:09

+0

[PreferenceScreen class not found]可能的重複(http://stackoverflow.com/questions/6025349/preferencescreen-class-not-found) – 2016-05-27 12:12:55

回答

13

如果preferences.xml不在res/xml中,您應該將其移動到那裏。我猜測這可能是你問題的根源。

+0

這是問題所在。所以我不能在圖形編輯器中查看/管理首選項屏幕? – Franziee 2012-07-18 12:17:20

+0

我不這麼認爲。我爲自己的東西使用的教程都假設您創建了一個活動並從xml文件加載首選項。 – wojciii 2012-07-18 12:30:03