I have a ListView. There is a TextView for each list row. For the TextView, I have set the following properties in the xml file:
android:autoLink="web"
android:focusable="false"
android:focusableInTouchMode="false"
Also, for the parent layout of the list row, I have set:
android:descendantFocusability="blocksDescendants"
The three focus-related properties were set after going through several SO answers for the problem in which the TextView used to become un-clickable if it contained a link (e.g., www.example.com).
Now the clicks are all registered properly. However, the problem now is the following: for TextViews which have a link, the setOnItemClickListener and setOnItemLongClickListener animations are lost. The animations are lost only when I click the TextView part of the ListView row. They still occur when I click the remaining part of the ListView row.
That is, the clicks are working, but the animation is lost. How do I get those back?
Related
Need to implement edit in runtime. Which one is the best way to achieve it.
Edittext in Listview or dynamic table layout(inflating row xml) with edittext
Update:
My listview contains 7-8 view(Text view) in a list item. On click edit button using view switcher changed textviews to edit text. To get the entered value in edittext listening onfocuschanged. It brings very slow performance. Any better way to achieve it?
Update:
If my listview have 100 list items. Each item having 7-8 edittext. Need to listen all the edittext focuschange. My app hangs. What should i do?
EditText within ListView can cause you great grief down the lane given that views are recycled in listview.
Say you have tapped on the second row in a listview where all item rows contain a edittext and you have set adjustResize in your AndroidManifest.xml; after the soft keyboard pops up, the focus goes into the first view that can accept the focus which in this case will be the first edittext (row) of your listview. Yes, you can tap again on the desired edittext to regain focus. But it is an annoyance nevertheless. If you set adjustPan, then I have seen the the problem does not exist as such; if I recollect correctly, you cannot scroll down all the way to the end of your list. Again, another annoyance.
I'd suggest, you go with a ScrollView if the number of items in the list are less. I have been trying to solve this for the last couple of days - I ended up doing this - I replaced the edittext's with textview's in the listview; tapping on the textview would bring up a dialog fragment that contains the edittext.
Have you looked into the concept of a ViewHolder to keep a reference to the items of the listview? That should solve your multiple focus listener problems.
I have developed the sample code of ExpandableListView in android. Data is being populated in Adapter and displaying in the ExpandableListView properly. but i am facing one severe issue of not expanding child view after tapping on Groupview.
The problem is when i add check box to the xml(parent xml) that is inflated in getgroupView() method child view does not get expanded after tapping Groupview.But, if checkbox is removed from the xml all works well.
Similar question has been posted in StackOverflow, but nothing seems to work.
If you place an item that is focusable in a list, then the list items no longer respond to clicks
Try to set the CheckBox android:focusable attribute to false.
In groupView layout set android:focusable="true" , android:clickable="true".
For checkbox set android:focusable="false"
I'm using a ListView to display the posts in a thread, if I scroll the list all the way up it should show a TextView or similar where I can choose the pagenumber. If I scroll down the TextView should move up like every other entry in this list.
The TextView must have a different layout.
I have a ListActivity-based activity that uses a context menu for the items. After adding an EditText to the row of a ListView, the context menu stopped working, and also the item does not react on a click. It seems that it is blocked somehow by the focus of the EditText. I can enter the EditText value, but I cannot get the earlier context menu, and I cannot start another activity via clicking the item.
I have possibly found the related comment that says:
Android doesn't allow to select list items that have focusable elements (buttons). Modify the button's xml attribute to:
android:focusable="false"
It should still be clickable, just won't gain focus...
... so I did the same for the EditText (I am not sure if the button case can be generalized for the EditText). Anyway, the item is clickable again, the context menu appears... However, the EditText part of the text stopped working now. (Actually, I did not implement the reaction to the EditText -- the keyboard simply does not appear.)
Is it possible to have the clickability of the list item and also make the EditText work the expected way?
I don't know if this would help you but it is a post I've found when I was trying to use a ListView with buttons inside.
ListView Tips & Tricks #4: Add Several Clickable Areas
Hope this helps.
I use an example to make this issue easy to understand.
I have a ListView. In each row, there's an customized RadioButton which is extended from RadioButton. I use setButtonDrawable to set the image of this button in getView(); I use ViewHolder method to hold the button.
holder.button.setButtonDrawable(drawable);
The ListView has 4 rows. In each screen, we can only see one row. Now the problem is: when I scroll the ListView, I found buttons in the first and the third item are the same, second and fourth are the same. But I'm sure I have set different images to them.
What's the problem? Does the button should be refresh after setButtonDrawable?
Thank you.