Переключатель Макет / Стиль переключателя отличается, когда я добавляю его в просмотр списка с customadaptor - PullRequest
1 голос
/ 21 мая 2019

Я использую переключатели и флажки в виде списка. Когда я заполняю представление списка с помощью пользовательского адаптера, стиль переключателя изменяется вместе со стилем флажков. Когда я добавляю его в представление списка без Custom Adapter в XML, его стиль по умолчанию. XML-макет элемента представления списка прилагается.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <!-- TextView for displaying question-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:orientation="horizontal"
        android:weightSum="2">

        <CheckBox
            android:id="@+id/checkBox"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:text="@string/check"
            android:textColor="@android:color/background_dark" />

        <TextView
            android:id="@+id/question"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="50dp"
            android:layout_marginLeft="20dp"
            android:padding="@dimen/activity_horizontal_margin"
            android:layout_gravity="center"
            android:textColor="#000"
            android:textSize="18sp" />

    </LinearLayout>

    <!-- RadioGroup for grouping of RadioButton-->

    <RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:orientation="horizontal"
        android:weightSum="3">

        <RadioButton
            android:id="@+id/rbutt1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"
            android:text="15"
            android:textColor="#000"
            android:textSize="12sp" />

        <RadioButton
            android:id="@+id/rbutt2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"
            android:text="30"
            android:textColor="#000"
            android:textSize="12sp" />

        <RadioButton
            android:id="@+id/rbutt3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"
            android:text="45"
            android:textColor="#000"
            android:textSize="12sp" />
    </RadioGroup>
</LinearLayout>

Добавление радиокнопок в список

    //=========================================================================================================
// get the string array from string.xml file
        questions = getResources().getStringArray(R.array.questions);
// get the reference of ListView and Button
        simpleList = (ListView) view.findViewById(R.id.simpleListView);
        submit = (Button) view.findViewById(R.id.submit);
// set the adapter to fill the data in the ListView
        CustomAdapter customAdapter = new CustomAdapter(getContext().getApplicationContext(), questions);
        simpleList.setAdapter(customAdapter);
        //=========================================================================================================

Добавлено с пользовательским адаптером

Добавлено в XML

...