ListView with clickable/editable widget
You might want to take a look at this issue. Having a focusable item in a row of a ListView
causes the OnItemClickListener
NOT to be invoked. However, that does not mean you cannot have focusable/clickable items in a row, there are some workarounds like this one.
Also, you can take a look at the Call Logs screen. It has a ListView
with clickable item(the call icon on the right).
See Source code here
Android: ListView elements with multiple clickable buttons
The solution to this is actually easier than I thought. You can simply add in your custom adapter's getView()
method a setOnClickListener() for the buttons you're using.
Any data associated with the button has to be added with myButton.setTag()
in the getView()
and can be accessed in the onClickListener via view.getTag()
I posted a detailed solution on my blog as a tutorial.
Listview OnItemClickListener working on MainActivity but not on similar TaskActivity
After trying the several recommended workarounds (like here) for ListView
rows containing a CheckBox
without any success, I'd like to suggest a different approach:
Use another, transparent View
which covers the whole row except for a small area around the CheckBox
. Let this View
have an OnClickListener
which triggers the opening of the TaskInfoFragment
.
Ideally one would use an interface so the TaskAdapter
could pass the clicked Task
to the TaskActivity
which in turn would show the Fragment
.
Several hours later... (@Guy, your hint that you "tried deleting all checkbox related code and xml, and the regular click problem persisted" made me exchange one component after another until I had it narrowed down to the row xml) I found the reason why the ListView
's OnItemClickListener
in TaskActivity
does not fire. The root ConstraintLayout
of the Task
list has an attribute which the root of the TaskList
list does not have: android:longClickable="true"
Removing this attribute makes the ListView
behave normally.
Android : How to set onClick event for Button in List item of ListView
You can set the onClick
event in your custom adapter's getView
method..
check the link http://androidforbeginners.blogspot.it/2010/03/clicking-buttons-in-listview-row.html
Widget with ListView in API 4
I have done something similar to this in one of my widgets. Listview is not supported in API 4, and while this "looks" like a ListView it is not. Its just cleverly positioned images, and text and a border around them that looks like a ListView does.
The arrows are images that when clicked tell the widget to go rerender all the stuff in the "ListView". So it sort of gives an approximation of a ListView on older devices, but you need to use arrows to change the content instead of flicking on the ListView.
Related Topics
How to Take a Screenshot of a Current Activity and Then Share It
Install Shows Error in Console: Install Failed Conflicting Provider
Lock Screen Orientation (Android)
Getting Bitmap from Vector Drawable
Is a Relativelayout More Expensive Than a Linearlayout
Android Listview Refresh Single Row
How to Marshall and Unmarshall a Parcelable to a Byte Array with Help of Parcel
How to Fix: "Hax Is Not Working and Emulator Runs in Emulation Mode"
Hide/Show Bottomnavigationview on Scroll
Adding Table Rows Dynamically in Android
Android Textwatcher.Aftertextchanged VS Textwatcher.Ontextchanged
Android 5.0 Android:Elevation Works for View, But Not Button
Android: Bitmapfactory.Decodestream() Out of Memory with a 400Kb File with 2Mb Free Heap
Gradle - Library Duplicates in Dependencies