开发者

Android checkbox example

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜