Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Radio button in list view

Tags:

android

I am showing list of sting in list view formate, i used default list view and placed a radio button by using simple_list_item_single_choice. But this shown the Radio button in right side, i want to display the radio button in left side. is that any possible to show the radio button in left side using default list view

like image 737
RAAAAM Avatar asked Apr 25 '11 06:04

RAAAAM


1 Answers

simple_list_item_single_choice.xml use CheckedTextView class

Here is the simple_list_item_single_choice.xml

 <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:gravity="center_vertical"
    android:checkMark="?android:attr/listChoiceIndicatorSingle"
    android:paddingLeft="6dip"
    android:paddingRight="6dip"
   />

You need to create a custom xml for your need and use a CheckBox to achieve your goal Here is your custom.xml

 <CheckBox
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:gravity="center_vertical"
    android:button="?android:attr/listChoiceIndicatorSingle"
    android:paddingLeft="6dip"
    android:paddingRight="6dip"
   />

Just use the custom.xml in place of simple_list_item_single_choice.xml in your code.

Hope it helps you.

like image 166
Tanmay Mandal Avatar answered Oct 21 '22 07:10

Tanmay Mandal