Kotlin recyclerView nextFocusDown - android

I need to make nextFocusDown on items in recyclerView. Every item has the same id, but to make nextFocusDown I need to have specific id. How shoudl I do this in recycerView to make focus on next edittext in list?

You can put focus on your edit text programmatically. Get the event when the user presses enter button or some button that tells you the user is done editing the first edit text. Then you can programmatically put focus on next item in recyclerview using following code:
edittext.setFocusableInTouchMode(true);
edittext.requestFocus();

Related

How to handle ListView containing EditText and CheckBox on each row item (Android)

i am trying to implement that, when click on edit button (shown last two in image)
then that row should be editable mode with specific edit text and then click on save button that updates value should be change.
But major issue is that when click on edit button that row is editable but in bottom some other row is also randomly editable automatically and i cant handle this .....totaly frustrated with this issue please give any solution for this.
another issue is that after edit value when scrool list then updated value change and orignal display there ...so how can i manage all that thing is there any demo which match with my requirement plsss help......
adpater class
getview method
save button click
edit button click
checkbox event
delete button click
position handle logic
position handle logic

How to activate an EditText field on a newly added item in a RecyclerView?

I have a list of items held in a RecyclerView. Now, these items each have an EditText view in them.
I'd like to activate (set focus to) the EditText of an item when it's added the first time. How do I do that?
To identify the relevant view, keep a reference to the newly added item in the adapter and when it's view is bound, call view.requestFocus() (see the docs).
To get focus and show the keyboard you would write something like this:
if(myEditText.requestFocus()) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
You need to clear focus if another EditText gets focus. This can be done with
myEditText.clearFocus()
Take note, that all the EditText views should have set their onFocusChangeListener to the same listener

Which is better way to implement edit - listview with edittext or table layout with edittext

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.

EditText in listview losing control

I have added two textview(id, name), two edittext and two buttons(edit,save) in every row of listview, When edit button is clicked both edittext appears in that row(visibility is set to gone in XML) now all I want to do is allow user to add some contents in edittext and on pressing save button those contents will be reflected in textview and edittext will be disappeared again.
On edit buttons click view two edittext are appearing as expected but as soon as I type in any of the edittext they are getting refreshed. In debug mode I have found out that as soon as I am typing in Edittext getView() method called again & again and that's the reason behind refresh.
I have implemented empty onclicklistner on edittext so that when it get touched and typed it will not call getView but thats not working and I know that's a stupid attempt to solve problem.
Please tell what to do so that when I click or type in edittext it will not call getView().
You have to off focus from xml of edittext and button

Android GridView Focus Issueon children?

I have a GridView to which a custom adapter is set. getView() method of the custom adapter returns a LinearLayout with two TextView and an EditText arranged horizontally. I have made a custom numeric keyboard for entering text in the EditText. Keyboard contains NEXT and PREV buttons as well which are creating problems. I want NEXT button to automatically focus the next EditText in the next row and similarly PREV button. NEXT button onKeyPress seems like:
View v=getWindow().getCurrentFocus().focusSearch(View.FOCUS_FORWARD);
if(v!=null)
v.requestFocus();
The code seems right. The problem is, suppose currently only three rows are visible of gridView,if the focus is on the third EditText and NEXT is pressed,it then focuses on nothing. I dont know how to solve this issue. If anyone knows how to solve it.
Thanx in advance.
Can you maintain a collection of ids of all the editText's in the same order, while adding them for rendering.
In that case, for clickHandler or NEXT/PREV button, u can check following:
clickHandler of PREV: if present selection is first in list, then you might want to set focus on last element in list.
clickHandler of NEXT: if present selection is last in list, then you might want to set focus on first element in list.
Alternatively, if you do not want a list roll back functionality, you can just check the position of element in list, and handle the brink elements any way u want them to be.
Hope I understood your problem correctly.
HTH

Categories

Resources