开发者

Android: Alert Dialog with CheckedTextView

Ok guys..I have a problem... I need to create a dialog with 3 CheckedTextView. And when i open a dialog, second item should be checked...How to do that ? Code ...

@Override
protected Dialog onCreateDialog (int id) {

        AlertDialog.Builder builder = new AlertDialog.Builder(this);            
        builder.setTitle("Something..");
        builder.setInverseBackgroundForced(true);


        ListVi开发者_Go百科ew listView = new ListView(this);

        listView .setAdapter(new ArrayAdapter(Settings.this, android.R.layout.select_dialog_multichoice, new String {a ,b, c}));

        builder.setView(listView );


http://developer.android.com/guide/topics/ui/dialogs.html

check adding check boxes and radio buttons , One method would be ,

Have a flag through which you can decide which to check next time when you popup the dialog and set the radio button in code , get radio button view and use toggle()

Check radio buttons and checkbox,

http://developer.android.com/resources/tutorials/views/hello-formstuff.html

Another method would be to use CheckBoxPreference.

Hope it helps.


Try this listView.getAdapter().getItem(1);. if your 2nd list item is check box, then set it checked by setChecked(true);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜