jess-anders / two-way-gridview

An Android GridView that can be configured to scroll horizontally or vertically
650 stars 261 forks source link

Getting runtime exception in the Class TwoWayGridView #5

Open raeesaa opened 11 years ago

raeesaa commented 11 years ago

I am trying to use two way GridView in my project. I have created my own custom adapter for GridView. When I tried running application, I got following exception :

java.lang.ClassCastException: android.widget.AbsListView$LayoutParams cannot be cast to com.jess.ui.TwoWayAbsListView$LayoutParams at com.jess.ui.TwoWayGridView$HorizontalGridBuilder.onMeasure(TwoWayGridView.java:2872)

Is it because I am using my own custom adapter?

roma86 commented 11 years ago

i have exactly same exception

raeesaa commented 11 years ago

I am no longer using this repository. Could not resolve the issue.

DanAndersen commented 10 years ago

For anyone still having this issue, I just encountered it and found a solution for myself. Look at this StackOverflow: https://stackoverflow.com/questions/17882123/android-grid-view-with-images-and-sub-text-issue

When converting my existing code from using a GridView to a TwoWayGridView, I had had this bit of code in my adapter's getView() function:

imageView.setLayoutParams(new GridView.LayoutParams(85,85));

I had to make sure it was changed to:

imageView.setLayoutParams(new TwoWayGridView.LayoutParams(85,85));

In short, the issue happens when trying to do setLayoutParams() on the wrong kind of LayoutParams object.

regiszanandrea commented 7 years ago

Thanks @DanAndersen!