4

I have EditText inside ListView and i want to Enter some integer values in all the EditText .I have one Button outside the ListView onClicking that button i want to get the data from all the EditText from ListView and saveinside the database,and also my EditText id is same for all the EditText Can any buddy giving so sample code so i can proceed to nextstep. Thanks in advance.

Sachin Gurnani
  • 2,444
  • 7
  • 36
  • 45

2 Answers2

3

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

editText.setTag(position).

And where you have written the Listener just use getTag to take the position.

I have some other requirement that's why I have used the OnTouch listener. But to achieve above requirement that you have mention you have to use Textwatcher. same thing you have to use.

Inside the Listener :

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

This position is Unique for each of the row of the ListView.

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

mayur rahatekar
  • 4,410
  • 12
  • 37
  • 51
1

You can keep a TextWatcher on the EditText and store the text of EditText in some Data Collection(i.e. ArrayList) and on the Button Click just fetch the data from the Collection and store in the Database.

Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242
  • but my ListView contains two TextViews and one EditText and my EditText id same for all the rows . basically i want to get the data from textview and EditText and compare with eachother for all the row inside the ListView and theon button click in want store in database and one more the data in TextView inside ListView came from webservice , before Editing i want to campare, so plz help me out by giving some sample source code. – Sachin Gurnani Feb 06 '12 at 06:30
  • You need to do the working in the `getView()` by using `position` of the ListView item. – Lalit Poptani Feb 06 '12 at 06:32
  • But how can i get the position of listview because im not able to fire OnClickItemListner on listview because their is an edittext inside ListView . – Sachin Gurnani Feb 06 '12 at 06:35
  • can i achive it by fire onFocuse change on EditText . – Sachin Gurnani Feb 06 '12 at 06:37
  • `getView()` method has the position of the ListItem row. – Lalit Poptani Feb 06 '12 at 06:37