java - How to make checkbox in alert dialog align left? -
it possible modified checkbox align left in alert dialog?
this activity.java file
alertdialog dialog; final charsequence[] items = {" easy "," medium "," hard "," hard "}; // arraylist keep selected items final arraylist seleteditems=new arraylist(); alertdialog.builder builder = new alertdialog.builder(this); builder.settitle("select difficulty level"); builder.setmultichoiceitems(items, null, new dialoginterface.onmultichoiceclicklistener() { // indexselected contains index of item (of checkbox checked) @override public void onclick(dialoginterface dialog, int indexselected, boolean ischecked) { if (ischecked) { // if user checked item, add selected items // write code when user checked checkbox seleteditems.add(indexselected); } else if (seleteditems.contains(indexselected)) { // else, if item in array, remove // write code when user uchecked checkbox seleteditems.remove(integer.valueof(indexselected)); } } }) // set action buttons .setpositivebutton("ok", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int id) { // code when user clicked on ok // can write code save selected item here } }) .setnegativebutton("cancel", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int id) { // code when user clicked on cancel } }); dialog = builder.create();//alertdialog dialog; create outside onclick dialog.show(); }
.........................................................................
http://i.stack.imgur.com/rtpyb.jpg">
but... want checkbox displayed @ left side...anyone me.
you can put custom view in alertdialog. in view can align checkbox want. more read tutorial. http://www.pcsalt.com/android/create-alertdialog-with-custom-layout/#sthash.yn5edpax.fkwqjxbj.dpbs
Comments
Post a Comment