i want to update my selected item from listview, i can update with a single row, how can i update them if more than one item is selected?
here's my code:
myList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
myList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//TextView textView = (TextView) view.findViewById(R.id.item_version);
poss = position;
Cursor cursor = (Cursor) myList.getItemAtPosition
(position);
String id = cursor.getString(cursor.getColumnIndex(DBAdapter.KEY_ROWID));
String hl = cursor.getString(cursor.getColumnIndex(DBAdapter.KEY_HIGHLIGHT));
String[] from = new String[]{DBAdapter.KEY_NAME};
uid = id;
}
});
Here's my dbadapter code
public boolean updateRow(long rowId, String highlight) {
String where = KEY_ROWID + "=" + rowId;
ContentValues newValues = new ContentValues();
newValues.put(KEY_HIGHLIGHT, highlight);
return db.update(DATABASE_TABLE, newValues, where, null) != 0;
}
Here's my update code:
int myNum = 1;
myNum = Integer.parseInt(uid);
myDB.updateRow(myNum, "Sample updated item to be inserted");
Aucun commentaire:
Enregistrer un commentaire