R
RED-BARON
Fortgeschrittenes Mitglied
- 19
Hallo Ihrs
hab da mal wieder ne Frage:
eine von ListActivity erbende Klasse überschreibt onCreateDialog und ruft
die Methode showDialog( ID ) auf.
In onCreateDialog werden die Dialoge ( ja, nein, abbrechen ) wie folgt erstellt:
Vor jedem Aufruf von showDialog wird settings.app.PatName
geändert
Wenn jetzt im Dialog der "negative" Button gedrückt wird ( abbrechen )
und der Dialog erneut aufgerufen wird erfolgt KEIN Ereignis "
onCreateDialog" erneut aufgerufen.
Wird eine der anderen beiden Möglichkeiten gewählt hingegen wird
onCreateDialog ausgelöst.
Problem ist konkret, ich habe ne Liste mit Namen, beim anklicken
wird der Name aus der Liste mit im Dialog angezeigt, das funktioniert
nur beim ersten mal, wenn danach Abbrechen gedrückt wird kommt
in jedem anderen Dialog der zu erst angewählte Name...
Ich seh nur leider nicht den Grund, warum onCreateDialog nicht immer
aufgerufen wird
Hat wer dazu ne Idee ?
hab da mal wieder ne Frage:
eine von ListActivity erbende Klasse überschreibt onCreateDialog und ruft
die Methode showDialog( ID ) auf.
In onCreateDialog werden die Dialoge ( ja, nein, abbrechen ) wie folgt erstellt:
Code:
[LEFT][SIZE=2][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]return[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] AlertDialog.Builder(hbview.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2])[/SIZE][/SIZE][/LEFT]
[SIZE=2][SIZE=2].setIcon(R.drawable.[/SIZE]
[LEFT][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]alert_dialog_icon[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2])[/SIZE][/LEFT]
[LEFT][SIZE=2].setTitle(settings.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]app[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2].[/SIZE][I][U][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PatName[/COLOR][/SIZE][/COLOR][/SIZE][/U][/I][SIZE=2].subSequence(0, settings.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]app[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2].[/SIZE][I][U][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PatName[/COLOR][/SIZE][/COLOR][/SIZE][/U][/I][SIZE=2].length()))[/SIZE][/LEFT]
[LEFT][SIZE=2].setView(textEntryView1)[/SIZE]
[SIZE=2].setPositiveButton(R.string.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]alert_dialog_start_hb[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] DialogInterface.OnClickListener() {[/SIZE][/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onClick(DialogInterface dialog, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] whichButton) {[/SIZE][/LEFT]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* User clicked OK so do some stuff */[/COLOR][/SIZE][/COLOR][/SIZE] [/LEFT]
[LEFT][SIZE=2]Intent intent = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Intent();[/SIZE]
[SIZE=2]intent.setClass(hbview.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], hbtodo.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[LEFT][SIZE=2]startActivity(intent);[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]})[/SIZE]
[SIZE=2].setNeutralButton(R.string.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]alert_dialog_show[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] DialogInterface.OnClickListener() {[/SIZE][/LEFT]
[/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onClick(DialogInterface dialog, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] whichButton) {[/SIZE][/LEFT]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* User clicked Something so do some stuff */[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
[LEFT][SIZE=2]settings.[/SIZE][/LEFT]
[LEFT][SIZE=2]Intent intent = [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] Intent();[/SIZE]
[LEFT][SIZE=2]intent.setClass(hbview.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]this[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2], hbtodo.[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2]);[/SIZE]
[SIZE=2]startActivity(intent); [/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]})[/SIZE]
[SIZE=2].setNegativeButton(R.string.[/SIZE][I][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]alert_dialog_cancel[/COLOR][/SIZE][/COLOR][/SIZE][/I][SIZE=2], [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] DialogInterface.OnClickListener() {[/SIZE][/LEFT]
[/LEFT]
[LEFT][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/COLOR][/SIZE][/COLOR][/SIZE][/B][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] onClick(DialogInterface dialog, [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2] whichButton) {[/SIZE][/LEFT]
[LEFT][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* User clicked cancel so do some stuff */[/COLOR][/SIZE][/COLOR][/SIZE][/LEFT]
[LEFT][SIZE=2]dialog.dismiss();[/SIZE]
[SIZE=2]}[/SIZE]
[LEFT][SIZE=2]})[/SIZE]
[SIZE=2].create();[/SIZE][/LEFT]
[/LEFT]
[/SIZE]
Vor jedem Aufruf von showDialog wird settings.app.PatName
geändert
Wenn jetzt im Dialog der "negative" Button gedrückt wird ( abbrechen )
und der Dialog erneut aufgerufen wird erfolgt KEIN Ereignis "
onCreateDialog" erneut aufgerufen.
Wird eine der anderen beiden Möglichkeiten gewählt hingegen wird
onCreateDialog ausgelöst.
Problem ist konkret, ich habe ne Liste mit Namen, beim anklicken
wird der Name aus der Liste mit im Dialog angezeigt, das funktioniert
nur beim ersten mal, wenn danach Abbrechen gedrückt wird kommt
in jedem anderen Dialog der zu erst angewählte Name...
Ich seh nur leider nicht den Grund, warum onCreateDialog nicht immer
aufgerufen wird
Hat wer dazu ne Idee ?