Android Listview Arrayadapter - Checkbox/radio Button Arrangement
Is there a way to rearrange the checkboxes so that it appears before the text? I am using ArrayAdapter with simple_list_item_multiple_choice, ideally, I would like to see the check
Solution 1:
I found a way to fix the alignment.
After listView.setAdapter(arrayAdapter);
use listView.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
works like a charm.
Solution 2:
In the adapter, you could use a custom layout such as:
Construction of the array adapter
ArrayAdapter<String> adapter = newArrayAdapter<>(getContext(), R.layout.spinner_item);
XML File
<?xml version="1.0" encoding="utf-8"?><TextViewxmlns:android="http://schemas.android.com/apk/res/android"android:id="@android:id/text1"style="?android:attr/spinnerItemStyle"android:singleLine="true"android:textSize="20sp"android:padding="10dp"android:gravity="center_vertical"android:layout_width="match_parent"android:layout_height="wrap_content"android:ellipsize="marquee"android:background="@drawable/back"android:textAlignment="inherit"/>
In that case, the XML is a simple TextView, but it could be more complex. So, you could control the layout of your adapter in a more customized way.
Post a Comment for "Android Listview Arrayadapter - Checkbox/radio Button Arrangement"