I have a list view and the list contains 2 items, a TextView and a Button/EditText based on some logic as as 2 columns in a table row.
Now in the layout, where I have listview, I also have some button say Save. When I click Save, I should retrieve the values of Button/EditText in the Activity where Listview is residing and need to store them in db.
I am not able to figure out this situation. There could be many list rows, say if there are 5 list rows, then need to retrieve each of the values from the positions 0-4.
Please see the screenshot below to know how the list view looks.
Hope you can see the fields on the right side there. Next to COmments is the Edit text and next to Ship Date is a button.
Can anybody please help me or suggest me something?
Update:
I am now iterating the list view as below,
View vr;
EditText ee;
for (int i=0;i<=list.getLastVisiblePosition()-list.getFirstVisiblePosition();i++) {
//vr = list.getChildAt(i);
vr = list.getAdapter().getView(i, null, null);
ee = (EditText) vr.findViewById(i);
System.out.println(ee.getText().toString());
}
Edittext ee is always null in this case. I have tried uncommenting vr = list.getChildAt(i); But still it returns null.
Here there can be either Edittext ee or some other button in the same i position based on some requirement. But I'm not understanding why ee is null.
Referred the answer here Iterate through ListView and get EditText-Field values.
Any thoughts where I am going wrong?