Apologies, my example was too simple and once I expanded upon it I hit across the same problem.
See you have solved it now, please can you share this so we can all learn from it. Thanks, On Jul 23, 8:58 pm, eags <[email protected]> wrote: > This didn't work for me unfortunately. Were you having the same > problem where your list items were not clickable but could be selected > using the trackball? And setting duplicateParentState fixed it? > > I feel pretty fuzzy in general about the relationship between nested > views. It seems like something non-obvious is happening behind the > scenes here. > > On Jul 23, 3:13 am, Andrew <[email protected]> wrote: > > > > > Hi, I've been following this thread trying to get listviews working > > and think I may have cracked it. > > I'm new to Android development so dont bite my head off if its wrong > > but I got this working ok; > > > The key to it is the android:duplicateParentState="true" > > > I'm not sure which Layout you'll need to put it on yours but hopefully > > you can see how it works. > > > <?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:gravity="center_vertical" android:orientation="horizontal" > > android:minHeight="40sp"> > > > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > > android" > > android:layout_width="fill_parent" > > android:layout_height="fill_parent" > > android:layout_weight="1" android:orientation="horizontal" > > android:duplicateParentState="true"> > > > <TextView android:id="@+id/itemname" > > android:layout_width="fill_parent" > > android:layout_height="wrap_content" > > android:textSize="20sp" > > android:text="Item Name" /> > > > </LinearLayout> > > > <TextView android:id="@+id/duration" > > android:layout_width="wrap_content" > > android:layout_height="wrap_content" > > android:layout_gravity="right" > > android:layout_marginRight="20sp" > > android:layout_marginLeft="10sp" > > android:textSize="20sp" android:text="0 Days" /> > > > </LinearLayout> > > > On Jul 10, 9:44 am, eags <[email protected]> wrote: > > > > Bump. Mystery remains. Why can the entireListViewitem not be > > > madeclickable??? > > > > On Jul 9, 7:57 pm, eags <[email protected]> wrote: > > > > > And I tried making sure the first sub LinearLayout was not fill_parent > > > > for width or height. No dice. > > > > > On Jul 9, 7:52 pm, eags <[email protected]> wrote: > > > > > > Anyone?? Total mystery. I played around with .bringToFront() and > > > > > friends with no avail. I'm thinking the issue is simply that the list > > > > > item is simply completely covered by its children but that doesn't > > > > > really explain why TextView does work even when it is set to > > > > > fill_parent. > > > > > > On Jul 9, 5:11 pm, eags <[email protected]> wrote: > > > > > > > So I methodically tried removing items from my top level > > > > > > LinearLayout > > > > > > in the list item layout until clicking started working at the top > > > > > > level. It turns out that with LinearLayout, you can only have one > > > > > > child (total, not just immediate children) before clicking stops > > > > > > working. Then I found some example code where this works but they > > > > > > are > > > > > > using RelativeLayout and if you try to nest a LinearLayout inside it > > > > > > also stops working. > > > > > > > Honestly this all seems like utter nonsense to me. Is there someone > > > > > > who can explain things or point to a document so that all this makes > > > > > > some sense?? > > > > > > > Right now it seems like my options are, redo all my layouts using > > > > > > only > > > > > > relative (which just won't work for a more complicated layout like > > > > > > this one) or set a sub-element to beclickableand do the dance to > > > > > > figure out which list element that corresponds to. > > > > > > > Thanks again in advance for any information explaining this. > > > > > > > On Jul 9, 4:28 pm, eags <[email protected]> wrote: > > > > > > > > I did what you said and it worked. This is actually exactly what > > > > > > > the > > > > > > > Alarm Clock application does since when you click on an alarm it > > > > > > > doesn't select the entireListViewelement but just the clock and > > > > > > > message. However I still have a couple problems with this: > > > > > > > > 1. Why??? I find this behavior to be very confusing especially > > > > > > > when > > > > > > > other simpler list view item layouts work just fine at the top > > > > > > > level > > > > > > > (for example browser options clicking selects the entire element > > > > > > > including the checkbox which is what I want) > > > > > > > 2. This actually really screws up my code because now my > > > > > > > OnItemClickListener which was returning to me the index which is > > > > > > > useful now just has a reference to the element. I could probably > > > > > > > figure out the index either way but it seems like a pointless > > > > > > > mess. > > > > > > > > Is there some piece of documentation you could point me to that > > > > > > > explains what is going on here? It seems very quirky to me. > > > > > > > > On Jul 8, 11:20 pm, Radzell <[email protected]> wrote: > > > > > > > > > It looks like what you need is not to put androidclickablein the > > > > > > > > view group but in the individual view that you want to > > > > > > > > makeclickable > > > > > > > > ie > > > > > > > > <?xml version="1.0" encoding="utf-8"?> > > > > > > > > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > > > > > > > > android" > > > > > > > > android:orientation="horizontal" > > > > > > > > android:gravity="center_vertical" > > > > > > > > android:layout_width="fill_parent" > > > > > > > > android:layout_height="fill_parent" > > > > > > > > android:clickable="true"> > > > > > > > > > <LinearLayout > > > > > > > > android:layout_height="wrap_content" > > > > > > > > android:layout_width="wrap_content" > > > > > > > > android:paddingLeft="10sp" > > > > > > > > android:layout_weight="1" > > > > > > > > android:orientation="vertical" > > > > > > > > android:clickable="true" android:focusable="true" > > > > > > > > android:focusableInTouchMode="true"> > > > > > > > > <LinearLayout > > > > > > > > android:layout_height="wrap_content" > > > > > > > > android:layout_width="fill_parent" > > > > > > > > android:gravity="bottom" > > > > > > > > android:orientation="horizontal" > > > > > > > > android:clickable="true" > > > > > > > > //like this make the individual linearllayouclickablenot the > > > > > > > > group > > > > > > > > then make the click lister t test with a toast > > > > > > > > > On Jul 9, 1:32 am, eags <[email protected]> wrote: > > > > > > > > > > Hi, bump again. > > > > > > > > > > On Jul 8, 7:52 pm, eags <[email protected]> wrote: > > > > > > > > > > > Bump. > > > > > > > > > > > Hi someone please? I think this is probably something > > > > > > > > > > pretty simple > > > > > > > > > > that I'm just missing. > > > > > > > > > > > Thanks. > > > > > > > > > > > On Jul 8, 1:20 pm, eags <[email protected]> wrote: > > > > > > > > > > > > I created a custom layout and adapter for a list view but > > > > > > > > > > > now I cannot > > > > > > > > > > > make itclickable? Is there anything to look out for > > > > > > > > > > > here? My list > > > > > > > > > > > item looks almost exactly like the alarms in the Alarm > > > > > > > > > > > Clock app that > > > > > > > > > > > comes installed with Android. Everything seems to work > > > > > > > > > > > fine but now > > > > > > > > > > > clicking on the list item does nothing. > > > > > > > > > > > > I tried setting android:clickable=true and > > > > > > > > > > > android:focusable=true > > > > > > > > > > > (which already works because I can select using the > > > > > > > > > > > trackball but I > > > > > > > > > > > was just trying random things. > > > > > > > > > > > > I can post code here if anyone needs more details. > > > > > > > > > > > Thanks in advance > > > > > > > > > > > for any help.- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

