简体   繁体   中英

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

I'm having some problems with my android project in eclipse.

I have two XML layout files, and both contain ListViews.

The ListViews are working perfectly on my Android phone, but eclipse wont open the design window, giving the following error:

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

Both files contains the following code:

<?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>

Any suggestions?

It might be the

android:fastScrollAlwaysVisible="true"

that is bugging your application. Try deleting it.

Just change device in layout preview.

Small screens (inches < 7) cannot preview properly. Select 10.1'' for example.

I don't have any android:fastScroll* option in any of my layouts, however I do receive this error on any version of Android, but can't reproduce on any test devices.

Turns out this occurs when I attach an Adapter declared like this:

MyAdapter implements ListAdapter

Changing to the following actually fixes the issue:

MyAdapter extends BaseAdapter

EDIT: Turns out users where using an Xposed module to forst fastscroll on app ListView's! Unfortunately that module is pretty dumb and doesn't check the adapter type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM