Bob,

The error is caused by addHeaderView wrapping your ListView adapter.

public void addHeaderView (View v)
Since: API Level 1

Add a fixed view to appear at the top of the list. If addHeaderView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.

NOTE: Call this before calling setAdapter. *This is so ListView can wrap the supplied cursor with one that will also account for header and footer views.*

So if you call getAdapter right after calling setAdapter (and in case there was a prior addHeaderView), you will not get back the same object, you will get a HeaderViewListAdapter. It's actually in your logcat.

Your adapter implements Filterable, but android.widget.HeaderViewListAdapter does not. Hence the class cast exception.

I can think of two ways to fix this:

- Do not use addHeaderView, instead add the header layout into the ListView's parent, positioned right above.

- Might also work: keep a reference to your original adapter object, the one that implements Filterable, and use that object reference for casting to Filterable.

-- Kostya

10.12.2010 21:39, TreKing ?????:
On Fri, Dec 10, 2010 at 12:36 PM, bobetko <[email protected] <mailto:[email protected]>> wrote:

    I call setHeaderView in onCreate, before I set myAdapter.


OK, that eliminates that.

    ((Filterable) adapter).getFilter().filter(s);


Does your adapter extend Filterable?

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago transit tracking app for Android-powered devices

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to