2

I am working on list view in android where i have placed edit text on each item of a list view now I want to select some items of that list view and want to get data of the selected ones only ,I means items where I have filled edit text.

I am using list adapter to get data into the list view, now suggest me something if you got what I mean.

tshepang
  • 12,111
  • 21
  • 91
  • 136
  • You can use focus change listener for each edit text of list view , when you change focus to go another editext, you can save value in arraylist with its position. if it helps then vote me ;) – abhi Jun 20 '13 at 11:31

1 Answers1

0

From Android: Access child views from a ListView:

int wantedPosition = 10; // Whatever position you're looking for
int firstPosition = listView.getFirstVisiblePosition() - listView.getHeaderViewsCount(); // This is the same as child #0
int wantedChild = wantedPosition - firstPosition;
// Say, first visible position is 8, you want position 10, wantedChild will now be 2
// So that means your view is child #2 in the ViewGroup:
if (wantedChild < 0 || wantedChild >= listView.getChildCount()) {
  Log.w(TAG, "Unable to get view for desired position, because it's not being displayed on screen.");
  return;
}
// Could also check if wantedPosition is between listView.getFirstVisiblePosition() and listView.getLastVisiblePosition() instead.
View wantedView = listView.getChildAt(wantedChild);

And then:

EditText yourEditText = (EditText)wantedView.findViewById(R.id.yourEditTextId);
Community
  • 1
  • 1
Jakub Kozłowski
  • 493
  • 1
  • 6
  • 13