2012-04-12 48 views
4

我在eclipse中遇到了一些與我的android項目有關的問題。無法在圖形佈局中打開XML文件:FakeAdapter無法轉換爲BaseAdapter

我有兩個XML佈局文件,都包含ListViews。

的列表視圖是我的Android手機上可以正常使用,但日食不會打開設計窗口,給了以下錯誤:

com.android.layoutlib.bridge.impl.binding.FakeAdapter cannot be cast to android.widget.BaseAdapter 

這兩個文件包含以下代碼:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<ListView 
    android:id="@+id/cardList" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fadeScrollbars="true" 
    android:fastScrollAlwaysVisible="true" 
    android:fastScrollEnabled="true" 
    android:scrollbarSize="30dp" 
    android:scrollbarStyle="insideOverlay" > 
</ListView> 

</LinearLayout> 

任何建議?

+0

這似乎是Eclipse的ADT插件中的一個錯誤。確保您使用的是當前版本的ADT和SDK開發人員工具。 – CommonsWare 2012-04-12 13:15:25

+0

刪除'android:fastScrollEnabled =「true」'和'android:fastScrollEnabled =「true」' – 2013-10-18 05:57:20

回答

15

這可能是

android:fastScrollAlwaysVisible="true" 

被竊聽你的應用程序。嘗試刪除它。

+0

+1它有效,但它的完全瘋狂...:s – Farhan 2012-04-19 20:18:53

+1

也可以在刪除'android:fastScrollEnabled =「true」時運行 – 2013-10-18 05:56:29

+0

這背後的原因是什麼?你可以解釋嗎。? – 2014-01-09 04:38:06

1

只需在佈局預覽中更改設備即可。

小屏幕(英寸< 7)無法正常預覽。例如,選擇10.1''。

0

我的任何佈局中都沒有任何android:fastScroll *選項,但是我在任何版本的Android上都收到此錯誤,但無法在任何測試設備上重現。

原來,發生這種情況時,我附上聲明如下的適配器:

MyAdapter implements ListAdapter 

更改爲實際下列修復該問題:

MyAdapter extends BaseAdapter 

編輯:原來的用戶,其中使用Xposed模塊以在應用程序ListView上快速滾動!不幸的是,該模塊非常笨,並且不檢查適配器類型。