Android EditText inside ListView?

I have an EditText inside a ListView, and I want to enter some integer values ​​in the entire EditText. I have one button outside the ListView onClicking that I want to get data from the entire EditText from the ListView and save it to the database, and also my EditText ID is the same for all EditText. Can any buddy give such sample code so that I can go to nextstep. Thanks in advance.

+4
source share
2 answers

You can use setTag and getTag to find out the position of the Editext Inside Listview. Inside the getView method use setTag

editText.setTag (position).

And where you wrote the listener, just use getTag for the position.

I have another requirement why I used the OnTouch listener. But to achieve the above requirement that you mentioned, you need to use Textwatcher. same thing you need to use.

Inside the listener:

int position = (Integer) view1.getTag ();

This position is unique for each row of the ListView.

You need to do setTag Inside the getView () method of the BaseAdapter class. after line if (rowview == null) {}

+3
source

You can save the TextWatcher to an EditText and save the EditText text in some Data Collection(ie ArrayList) and push-button Click only fetch data from the collection and store in Database .

+1
source

Source: https://habr.com/ru/post/1394959/


All Articles