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
}
}
});
精彩评论