ScrollView childrens loses focus when scroll - android

I have a listview and button in a scrollview. When i scroll both list and button loses focus. When i tap on button it did not work but next time i tap it works i think button loses focus and focus is towards scrollview how to handle this please help

Never put ListView inside a ScrollView. ListView handles scrolling, and wrapping it in a ScrollView can cause problems with focus, touch-events etc. If you want other Views added to the top or bottom of you list, simply use ListView.addHeaderView() or ListView.addFooterView()

Scroll view can have only one child, put your button and listview in common layout and try out.

Related

Change focus in RecyclerView in single vertical click

I am building an app for Android TV by using Nested RecyclerView. Root is vertical RecyclerView which has rows with Horizontal RecyclerView.
I want to change the focus on the single click and want to keep the scroll position static. But scrolling is always happening at the bottom of the view for horizontal and vertical both.
I am using the focus listener to scroll to top
verticalRLVLayout.scrollToPositionWithOffset(rowNumber,0);
horizantalRLVLayout.scrollToPositionWithOffset(columnNumber, 0);
This is not working always and i don't see this is the best option.
Is there any way by which if we have fixed height of each row the single click will change the focus always.
Going upward in the RecyclerView, causes new row to slide towards right and focus goes to last visible tile on the previous row. Why this is happening, any idea ?
Thanks

Unclickable footerView while ListView is scrolling

I have a listView, with a footer attached to it, which is Button. This Button works fine when there is no Scrolling involved.
When the listView is scrolling, it becomes unclickable, like the other items in the ListView. Since it takes some time after the View have reached bottom, and the View actually stops "Scrolling", the footer(Button) is unclickable for a sec or 2. Is it possible to make an item, in this case a ListView footer, clickable while the ListView is scrolling? Or another clever solution to this issue?
try to make the button.setClickable(true). it should be clickable during the scrolling
This sounds like another one of a very long list of problems with ListView stealing touch events from its child views. The solution is to use RecyclerView instead. ListView is essentially deprecated and RecyclerView is the replacement.

Android Expandable ListView with EditText

I am currently using an ExpandableListView with a EditText as a child item. I want to give focus to the EditText when the item is expanded and automatically display the keyboard.(This turned out to be more difficult than what I expected. I can give focus to the EditText(using this post Focusable EditText inside ListView), but the keyboard is either never shown or it blinks and then hides itself).
Is a ListView the best approach to do this? Should I rather be looking at creating dynamic views inside a LinearLayout of a ScrollView?
Any suggestions/Ideas?
Sounds like some other view other than your TextView is receiving focus after your TextView receives focus. I would debug by overriding onFocus events on some Views and seeing if they get hit after your TextView.

Prevent onFocusChanged firing when ScrollView is scrolled

I have a problem where I have several TextView objects in my Activity. More than can fit on the screen view so I have placed them inside a ScrollView.
Now each TextView item is placed into a RelativeLayout before placing onto the ScrollView.
Each RelativeLayout object then has onClickListener and onFocusChangedListeners assigned.
Each Listener implements a method that pops up a dialog to enable the user to edit the value stored by the TextView.
The problem that is occuring is that when the screen is scrolled the onFocusChangedListener event is fired causing the dialog to appear for several items at a time.
Is it possible to detect if the Scrollview is scrolling and prevent the onFocusedChanged event firing?
I can post code if required but its quite large as the items added to the page are done so dynamically. This also means there is no xml for the layout.
I looked at using the ScrollView onTouchListener to add a flag ignoreFocusChange but it appears this would not work as the event was hit sveral times for one swipe/fling on the screen.
Please help
Regards,
Iain
After spending some time on this I found that the best solution for me was to remove the onFocusChangedListener and replace it with onTouchListener

Prevent ScrollView to focus on child elements during scrolling?

I have a ScrollView in which I have a quite long form, mainly using EditText elements. The problem is, that when the user scrolls around in this form, ScrollView changes the focus constantly. It seemed to me, that it assigns focus to the first element on screen when the user stops touching the screen, and the fling motion triggers.
How can I disable this?
Just a thought that you can make EditText as non-focusable elements. And when user will click on any item in ListView you can make that particular element focusable again.

Categories

Resources