I have a customized ListView. Each row has an
EditText, Buttons & TextView. In order to make the ListView items clickable I have kept
android:descendantFocusability="blocksDescendants" for row layout. If I don’t keep the descendantFocusability I am not able to implement an action for
onItemClick. If I keep descendantFocusability the
EditTextwhich is present in my row is not gaining focus. I want the
EditText focusable and also I should be able to click on each row to navigate to another
Activity. Can anyone please help me in this. Thanks all.
Edit : In the CustomAdapter for EditText, I tried keeping
onClickListenerwhere I requestFocus but that does not seem to work.
please Don’t use setOnItemClickListener for item click .. i think that you should be use item view click inside adapter method
Remove this from main list item layout
Thanks and enjoy this code !
Try to add this line to your activity in the manifest.xml
you do like this:
first set in your listview’s
then you want row to be clicked:
for this in your customAdapter you should do like this
It will work.
By default, your items should now have the click option, when you made
android:focusable="false" in listview.
No need to use
descendantFocusability in listview.
Create ArrayList add data into the arraylist.
1)create adapter for the listview and set the position as tag for the edittext.
2)Normally,when scrolling the item position will change.So,you have to get the edittext tag and set it into the edittext id.from that you can avoid the change of the item position.
Finally,add the text watcher to the edittext and store the changes into correct position in the list.