felipecsl / AsymmetricGridView

Android ListView that mimics a GridView with asymmetric items. Supports items with row span and column span
http://felipecsl.com/AsymmetricGridView
MIT License
1.84k stars 431 forks source link

OnItemClickListener issues with specified layouts #15

Open flightz8403 opened 10 years ago

flightz8403 commented 10 years ago

Hi Felipe,

Great library. It basically has all the functionalities that fits my needs.

This is the layout that I am trying to use in my app:

u9k2r

I modified the code in the sample app with the following in order to achieve my desired layout:

adapter.appendItems(getMoreItems(5)); listView.setAllowReordering(true); listView.setRequestedColumnCount(4); listView.determineColumns(); listView.setAdapter(adapter);

listView.setOnItemClickListener(this);

In getMoreItems(), the item in the first position (index = 0) has a row/column span of 2 while the others have a row/column span of 1.

However, the OnItemClickListener() stopped firing in Android 2.3.x for this layout.

Thanks.

tgamez commented 10 years ago

Hi Felipe and flightz8403,

I have the same problem in Android 2.3.x !!

In my case, onClick is not fired only in the first cell of the grid, all the other cells are firing properly. Moreover, when any other element on the screen is clicked, the first cell start to work, and fires onClicks, include the previous onClicks that has not fired, as they are waiting on the event queue. It's like, this clicks on the first cell are been queued but not fired until another UI element queue another click, in that moment all the events are fired, either from first cell and the other UI element.

In my case, the layout is like a 3 columns and 2 rows symmetric grid.

thanks a lot,

tgamez commented 10 years ago

Hi again,

I think it's a race condition between ViewPager and ICSLinearLayout. I have checked if I disable ViewPager onClicks are fired properly.

The Issue is commented in ActionBarSherlock project:. https://github.com/jakewharton/actionbarsherlock/issues/442#issuecomment-6132410

I have trying the workaround pointed in the link, repopulating Grid after viewPager is layout, but I'm not sure where make the call. I don't know when ViewPager are finishing its layout method, which is that mess the grid up.

Another workaround is to change ICSLinearLayout for LinearLayout, but I think the cell insets are lost, right ?

thanks,

tgamez commented 10 years ago

Finally, I have change reference to ICSLinearLayout to LinearLayout, as I haven't succeed with the other solution. Hopefully cell insets are working !!

felipecsl commented 10 years ago

@tgamez thanks for your investigation on this issue. Were you able to confirm this was an issue specifically related to ICSLinearLayout on Gingerbread (Android 2.3.x)?