开发者

Android: Alert Dialog with CheckedTextView

开发者 https://www.devze.com 2023-02-08 07:15 出处:网络
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 ...

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

精彩评论

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