开发者

Android checkbox example

开发者 https://www.devze.com 2023-04-03 05:08 出处:网络
I am trying to create an android application program..Is this possible to place the checkbox within the textview..if possible means t开发者_如何学Goell some example..Thanks in advanceJust inflate andr

I am trying to create an android application program..Is this possible to place the checkbox within the textview..if possible means t开发者_如何学Goell some example..Thanks in advance


Just inflate android.R.layout.select_dialog_multichoice and you'll get a textview with a checkbox!

It's actually a CheckedTextView, so do it like

CheckedTextView whatever = (CheckedTextView) getLayoutInflater().inflate(android.R.layout.select_dialog_multichoice, null);


CheckBox cb = new CheckBox(context);
                cb.setText("message");
                cb.setOnCheckedChangeListener(new OnCheckedChangeListener()
                {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
                    {
                        if ( isChecked )
                        {
                            // perform logic
                        }

                    }

                });
0

精彩评论

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