If you have problems after scrolling, this is a recycling view that will launch you. You basically need to set up an array to hold the contents of EditTexts, so when scrolling they will not get mixed up. You did not say what your list supports, but I have a list with edittexts contained here, and here is how I process it (from the cursor, but you can adapt it for the ArrayAdapter):
public class CursorAdapter_EditText extends SimpleCursorAdapter { private static Cursor c; private Context context; public static String[] quantity; private int layout; public CursorAdapter_EditText(Context context, int layout, Cursor c, String[] from, int[] to) { super(context, layout, c, from, to); CursorAdapter_EditText.c = c; this.context = context; this.layout = layout; initializeQuantity();
Then I have a button outside the array that processes it back to my database as follows:
commit.setOnClickListener(new OnClickListener() { public void onClick(View v) { int i = 0; itemCursor.moveToFirst(); while (itemCursor.isAfterLast() == false) { if (CursorAdapter_EditText.quantity[i].equals("")) { CursorAdapter_EditText.quantity[i] = "0"; } ; int tempQty = Integer .parseInt(CursorAdapter_EditText.quantity[i]); if (tempQty != 0) { mDbHelper.createListItem(listId, itemCursor .getInt(itemCursor .getColumnIndex(GroceryDB.ITEM_ROWID)), tempQty, 0); } i++; itemCursor.moveToNext(); } } });
source share