1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| protected Dialog onCreateDialog(int id){
// Auto-generated method stub
// ***********************************************************
// Ecran principal: étape3 création du menu & boite de dialogue Code:1-4
// ***********************************************************
switch(id) {
case DIALOG_ID_SETTINGS_TEMP_UNIT :
//Toast.makeText(this, "Dans l'item!", Toast.LENGTH_LONG).show();
return new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_info)
.setTitle("Unité de température")
.setSingleChoiceItems(CHOIX_UNITE, 0/*pre-checked item*/, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int choiceItemId){
String valueToWrite;
valueToWrite = (String) CHOIX_UNITE[choiceItemId];
Tools.setPreferences(MainScreen.this, Tools.PREF_TEMPERATURE_UNIT_ID, valueToWrite);
}
})
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton){
// Update the display according to the unit user choice
//...
}
})
.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which){
// nothing to do... just leave
}
})
.create();
default:
break;
}
return super.onCreateDialog(id);
} |
Partager