How to put text above or below using a checkbox?

How to put text above or below using a checkbox? Is this possible with checkBox in android?

+4
source share
2 answers

try using Layout , even LinearLayout add LinearLayout to Layout and add TextView up or down to Checkbox

+1
source

Here is what I did for my project:

  LinearLayout llsomething = new LinearLayout(this); Checkbox cbSomething = new CheckBox(this); TextView tvSomething = new TextView(this); tvSomething.setText(R.string.something); llsomething.addView(cbSomething); llsomething.addView(tvSomething); 

EDIT:

You can also make your layout clickable to make it more "natural":

 llSomething.setClickable(true); llSomething.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LinearLayout layout = (LinearLayout) v; CheckBox check = (CheckBox) layout.getChildAt(0); if(check.isChecked()) check.setChecked(false); else check.setChecked(true); } } 
0
source

All Articles