Вопросы опроса в RecyclerView - PullRequest
0 голосов
/ 28 апреля 2020

Я пытаюсь создать динамический c фрагмент опроса, и я пытаюсь создать RecyclelerView, который отображает вопросы, есть 4 доступных типа вопросов (текст, множественный выбор, да или нет и ранжирование по звездам) , Идея заключается в том, что каждый вопрос будет отображаться по-разному, когда дело доходит до ответа.

Правильно ли это делать с помощью recyclerView, и если да, то как должен выглядеть макет элемента recyclerView, поскольку я должен учесть все эти типы вопросов?

То, что у меня есть сейчас, просто для того, чтобы показать вопрос, инструкции и, если вопросы требуются или нет

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="@dimen/D20dp"
    android:background="@android:color/white">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/question_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:text="asdfasdfds group"
            android:textColor="@color/mediumBlue"
            android:textSize="20sp"
            app:layout_constrainedWidth="true"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintWidth_percent="0.90" />

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal"
            app:layout_constrainedWidth="true"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintWidth_percent="0.1">

            <TextView
                android:id="@+id/question_optional"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/red"
                android:textSize="24sp"
                android:text="" />

        </LinearLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>

    <TextView
        android:id="@+id/question_instructions"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/D5dp"
        android:text="instructions"
        android:textColor="@android:color/black"
        android:textSize="14sp" />



</LinearLayout>

Информация в каждом вопросе такая, информация, которая действительно нужно все, кроме user_id, survey_section_id, image, video, created_at, update_at и pivot.

{
   "id":1,
   "question":"asdf",
   "instruction":"asdf",
   "user_id":1,
   "survey_section_id":1,
   "response_type_id":1,
   "optional":0,
   "num":null,
   "rank":null,
   "show_text":null,
   "image":null,
   "video":null,
   "created_at":"2020-04-20 11:03:22",
   "updated_at":"2020-04-20 11:03:22",
   "pivot":{
      "survey_id":1,
      "survey_question_id":1,
      "order":0
   },
   "survey_question_option":[]
}

survey_question_option - это варианты с несколькими вариантами ответа на вопрос, и это также может быть любое количество вариантов.

Какой мой лучший курс действий?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...