java - Editing an alert dialog inside an on-click listener -


the following alert dialog has title , 4 items (i.e red, green, blue , black). change icon every time 1 of these items selected.

here's code:

final alertdialog.builder alertdialog = new alertdialog.builder(this); final charsequence[] items = {"red", "green", "blue", "black"};  alertdialog.settitle("pick color");  alertdialog.setsinglechoiceitems(items, 1, new dialoginterface.onclicklistener() {      @override     public void onclick(dialoginterface arg0, int num) {         switch(num) {             case 0: alertdialog.seticon(r.drawable.red);             break;              case 1: alertdialog.seticon(r.drawable.green);             break;              case 2: alertdialog.seticon(r.drawable.blue);             break;              case 3: alertdialog.seticon(r.drawable.black);             break;             }     } }); 

i can attest fact .seticon() methods being called; there no changes made aesthetics of alert dialog. effectively, icon not being changed though correct method executed.

can please explain how this.

your setting icon alertdialog builder, should alertdialog itself. change:

alertdialog.seticon(r.drawable.xxx); 

to:

((alertdialog)arg0).seticon(r.drawable.xxx); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -