M
muck
Ambitioniertes Mitglied
- 7
Hallo zusammen,
zwei Fragen zu setItemChecked:
1. Wie kann ich beim erstellen der ListView Einträge bereits anhacken? Die Info welche das sein müssen habe ich im Ergebnis meiner DB-Abfrage (ispoen):
2. Wenn ich einen Eintrag in der Liste anklicke, hackt er den darauffolgenden Eintrag ebenfalls an Ich mache lediglich:
Im Voraus vielen Dank.
zwei Fragen zu setItemChecked:
1. Wie kann ich beim erstellen der ListView Einträge bereits anhacken? Die Info welche das sein müssen habe ich im Ergebnis meiner DB-Abfrage (ispoen):
Code:
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] showProductList() {[/SIZE]
[SIZE=2]Cursor productList = [/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]dbConn[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].rawQuery([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"SELECT _id, count || unit || ' ' || name as sum, isopen FROM products WHERE irshoppinglists = ?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] String[] {[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]strListID[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]});[/SIZE]
[SIZE=2]startManagingCursor(productList);[/SIZE][/LEFT]
[LEFT][SIZE=2]SimpleCursorAdapter productListAdapter = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] SimpleCursorAdapter ([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], R.layout.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]product_list_view[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], productList, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] String[] {[/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"sum"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]}, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][] {R.id.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]text1[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2]});[/SIZE]
[SIZE=2]setListAdapter(productListAdapter);[/SIZE][/LEFT]
[SIZE=2]}[/SIZE]
2. Wenn ich einen Eintrag in der Liste anklicke, hackt er den darauffolgenden Eintrag ebenfalls an Ich mache lediglich:
Code:
[LEFT][SIZE=2][COLOR=#646464][SIZE=2][COLOR=#646464]@Override[/COLOR][/SIZE][/COLOR][/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]protected[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onListItemClick(ListView lv, View v, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] pos, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]long[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] id) {[/SIZE]
[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]super[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2].onListItemClick(lv, v, pos, id);[/SIZE]
[SIZE=2]lv.setItemChecked(([/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]) id, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]true[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE][/LEFT]
[SIZE=2]}[/SIZE]
Im Voraus vielen Dank.
Zuletzt bearbeitet: