Android ListView with edittext in items - android

I have a ListView where every item has an EditText, when I focus on the last items the soft keyboard appears, but the EditText does not so it stays in the bottom of the screen, what can I do ?
I have this in my manifest
android:windowSoftInputMode="adjustPan|adjustResize"

I would suggest you to make the listview scroll to the clicked EditText, so (I guess) it will be displayed in the visible part of the screen.
As in this question Programmatically scroll to a specific position in an Android ListView, you should identify which item has been clicked and then scroll to it.

Try using Adapter's getLastVisiblePostition:
http://developer.android.com/reference/android/widget/AdapterView.html#getLastVisiblePosition()
Then on the click of EditText, setSelection for the ListView(depending on the height of soft keyboard and each item row of the ListView);
http://developer.android.com/reference/android/widget/AdapterView.html#setSelection(int)

Related

Navigate from last item to first item in a RecyclerView

I'm using a RecyclerView with list items that contain an EditText control with the android:imeOptions set to actionNext. When I tap the actionNext button on the on-screen keyboard the focus goes to the EditText control of the next list item as expected. If the focus is on the EditText of the last list item that is visible on the screen then the RecyclerView creates the next list item and its EditText control receives the focus as I would expect.
The problem I have is with what happens when I tap the actionNext button when the EditText control of the last list item of the entire collection of data items has the focus. I would like the RecyclerView to scroll to the top and set the focus on the EditText control of the list item which shows the first item of the data item collection, but the focus actually goes to the EditText control of the first list item that is visible.
For example if I have 8 items in my collection and only the last 5 items fit on the screen, when I tap the actionNext button on the EditText control of the last item, the focus goes to the EditText control of the 4th item instead of the 1st item as I'd like.
I tried to achieve this behavior using an OnKeyListener on the EditText control but it won't fire when I tap the actionNext button. Could someone point me in the right direction?

Spinner losing focus after item is selected

I have a dialog with a bunch of EditTexts and Spinners. They are all inside a ScrollView and the dialog can sometimes be large enough for the scroll bar to be required.
When I select an item from a spinner, it will lose focus and switch to the first EditText in the dialog. When they are all shown on the screen, this is not a big problem, but when the spinner is on the bottom, it will auto scroll to the top to select the first EditText. And that's where it becomes very annoying.
I have tried calling requestFocus() on the spinner inside it's itemSelectedListener but it did not work. I had the same problem with buttons. When they were clicked, the focus would be switched to the first EditText, but requesting focus inside the button's click listener solved it.
EDIT:
I have noticed that the spinners were not focusable. After setting setFocusable and setFocusableInTouchMode to true, the first EditText would no longer get selected, but the viewpoint would still be scrolled to it. How do I prevent this?

Android ListView scrolls to top after visibility change of an item

I've have a listview with some items inside it.
For some of these items, when the users clicks on a button, the buttons is hidden and a status label is showed.
This works fine, but the problem is that the listview scrolls to the top everytime I change the visibility of some item inside a listview.
Any suggestion to avoid this?
I want the listview to stay where it is.

Focus issue on a listview with fastscrollbar enabled

I'm having an issue with a listview.
It's displaying items with a checkbox on the right.
When I enables the fastscrolling, everytime I press on the checkbox, the fastscrollbar appears and it scrolls to the position I pressed rather than just checking the checkbox...
If it matters I enable the fastscrollbar dynamically depending on the number of items in the list.
How can I fix this focus issue ?
Edit: In fact I'm also having the same issue without a checkbox. When I press on the right of the listview item, it doesn't open the item like it should but it scrolls to the position I pressed. Same behavior in a GridView...

Reach bottom of listview, android?

I have listview in which data is being added dynamically.
When a click of the button, it goes to another activity and listview appears.
I want it to show the last elements of the listview on the click of the button?
How to do it?
You can scroll to bottom of listview by doing following:
listView.setSelection(listAdapter.getCount() - 1);

Categories

Resources