簡體   English   中英

無法在圖形布局中打開XML文件:FakeAdapter無法強制轉換為BaseAdapter

[英]Cannot open XML files in Graphical Layout: FakeAdapter cannot be cast to BaseAdapter

我在eclipse中的android項目遇到了一些問題。

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

ListViews在我的Android手機上完美運行,但是eclipse不會打開設計窗口,給出以下錯誤:

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>

有什么建議么?

它可能是

android:fastScrollAlwaysVisible="true"

這會擾亂你的申請。 嘗試刪除它。

只需在布局預覽中更改設備。

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

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

當我附加一個聲明如下的適配器時,會發生這種情況:

MyAdapter implements ListAdapter

更改為以下內容實際上解決了問題:

MyAdapter extends BaseAdapter

編輯:結果使用Xposed模塊的用戶在應用ListView上快速滾動! 不幸的是,該模塊非常愚蠢,並且不檢查適配器類型。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM