java - Cannot resolve method setItems android alert dialog -
i working on how add together arraylist alert dialog. when phone call alertdialog.setitems
getting cannot resolve method error. take , lead me towards how prepare this? in advance.
the code:
if(arraylistbluetoothdevices.size()<1) // checks if size of bluetooth device 0,then add together { // device arraylist. detectedadapter.add(device.getname()+"\n"+device.getaddress()); arraylistbluetoothdevices.add(device); final charsequence[] items2 = {"this here figure out how setitems phone call properly"}; alertdialog advertisement = new alertdialog.builder(context).create(); ad.settitle("pop found devices here"); ad.setitems(items2, null); ad.setbutton("somehow set work when arraylist pressed", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { //do stuff here ok bottom button } }); ad.show(); detectedadapter.notifydatasetchanged(); }
i see problem. in android docs, creating alertdialog , defining alertdialog.builder, setitems() method valid on alertdialog.builder. define 'ad' alertdialog.builder, create alertdialog builder , show this:
if(arraylistbluetoothdevices.size()<1) // checks if size of bluetooth device 0,then add together { // device arraylist. detectedadapter.add(device.getname()+"\n"+device.getaddress()); arraylistbluetoothdevices.add(device); final charsequence[] items2 = {"this here figure out how setitems phone call properly"}; alertdialog.builder adb = new alertdialog.builder(context).create(); adb.settitle("pop found devices here"); adb.setitems(items2, null); alertdialog advertisement = adb.create(); ad.setbutton("somehow set work when arraylist pressed", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { //do stuff here ok bottom button } }); ad.show(); detectedadapter.notifydatasetchanged(); }
read docs more info: alertdialog.builder, alertdialog
java android arraylist android-arrayadapter alertdialog
No comments:
Post a Comment