Problem with Android-Query and Adapter
Opened this issue · 5 comments
Hi,
I'm using Android-Query library to async load the image into my ImageView in my adapter.
When I use:
if (aq.shouldDelay(position, convertView, parent, url)) {
aq.id(holder.image).image(placeholder, 1.0f);
} else {
aq.id(holder.image).image(url, true, true, 200, 0, null, 0, 1.0f);
}
I've this error:
java.lang.ClassCastException: com.jess.ui.TwoWayGridView cannot be cast to android.widget.AbsListView
Anyone can help me?
Your stack trace is incomplete, it doesn't say which class.method tries to cast.
java.lang.ClassCastException: com.jess.ui.TwoWayGridView cannot be cast to android.widget.AbsListView
at com.androidquery.util.Common.shouldDelay(Common.java:307)
at com.androidquery.util.Common.shouldDelay(Common.java:340)
at com.androidquery.AbstractAQuery.shouldDelay(AbstractAQuery.java:2326)
at com.project.MyAdapter.getView(MyAdapter.java:105)
at com.jess.ui.TwoWayAbsListView.obtainView(TwoWayAbsListView.java:1526)
at com.jess.ui.TwoWayGridView$VerticalGridBuilder.onMeasure(TwoWayGridView.java:1620)
at com.jess.ui.TwoWayGridView.onMeasure(TwoWayGridView.java:285)
at android.view.View.measure(View.java:15848)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:477)
at android.view.View.measure(View.java:15848)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5012)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:15848)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1451)
at android.view.View.measure(View.java:15848)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:477)
at android.view.View.measure(View.java:15848)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5012)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:15848)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5012)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:302)
at android.view.View.measure(View.java:15848)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5012)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2189)
at android.view.View.measure(View.java:15848)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1905)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1104)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1284)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
The first 5 lines were enough. Can you share your code for com.project.MyAdapter.getView()?
if (aq.shouldDelay(position, convertView, parent, url)) {
aq.id(holder.image).image(placeholder, 1.0f);
} else {
aq.id(holder.image).image(url, true, true, 200, 0, null, 0, 1.0f);
}
Since you keep the code close to your chest...
Guessing that your AndroidQuery is the latest version...
at line 307 it seems to convert your "parent" parameter to AbsListView lv = (AbsListView) parent;
and com.jess.ui.TwoWayGridView extends TwoWayAbsListView, which extends TwoWayAdapterView, voila.