-2

Possible Duplicate:
How to Set the Checkbox on the right side of the text

I want to change the direction of the checkbox in android such that the text will be on the left and the checkbox is on the right. could you please help me?

Community
  • 1
  • 1
David
  • 3
  • 5
  • http://stackoverflow.com/questions/5000213/how-to-set-the-checkbox-on-the-right-side-of-the-text , http://stackoverflow.com/questions/3156781/how-to-show-android-checkbox-at-right-side – MysticMagicϡ Dec 19 '12 at 12:51
  • 1
    @David kindly spend few minutes to search the question and only if the question is not asked, raise the question. Simply don't ask repeated questions. – Aamir Shah Dec 19 '12 at 12:54

2 Answers2

1

I think its better to Use CheckedTextView for your requirement

Ram kiran Pachigolla
  • 20,647
  • 14
  • 56
  • 74
0

Take a look

http://developer.android.com/guide/topics/ui/controls/checkbox.html

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
<CheckBox android:id="@+id/checkbox_meat"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/meat"
    android:onClick="onCheckboxClicked"/>
<CheckBox android:id="@+id/checkbox_cheese"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/cheese"
    android:onClick="onCheckboxClicked"/>
</LinearLayout>

Within the Activity that hosts this layout, the following method handles the click event for both checkboxes:

public void onCheckboxClicked(View view) {
   // Is the view now checked?
  boolean checked = ((CheckBox) view).isChecked();

 // Check which checkbox was clicked
  switch(view.getId()) {
    case R.id.checkbox_meat:
        if (checked)
            // Put some meat on the sandwich
        else
            // Remove the meat
        break;
    case R.id.checkbox_cheese:
        if (checked)
            // Cheese me
        else
            // I'm lactose intolerant
        break;
    // TODO: Veggie sandwich
  }  
 }