CheckBox.setText not working (Android)

CheckBox checkBox = new CheckBox(activity);
CheckBox.setText("Hello");

I tried to set the text after the checkbox as above. But it didn’t show me anything. Any suggestions?

+3
source share
1 answer

First: you try to set the text using the class nameCheckBox

it must be an instance CheckBox, for example:

CheckBox checkBox = new CheckBox(activity);
checkBox.setText("Hello");

Second:

You tried to add checkBox to your Activity Content , how is it?

this.setContentView(checkBox);

EDIT: : the this , maybe it will help you

+6
source

All Articles