#java #android-studio
Вопрос:
**Я работаю в нашем дипломном проекте, мобильном приложении для оценки. И мне трудно понять, как я могу сделать так, чтобы в каждом текстовом представлении было 5 кнопок, чтобы можно было выполнить оценку. Или мне нужно что-то еще, чтобы сделать то, что я хочу. Я спрашиваю о ваших великих умах. Спасибо.
Чтобы было ясно: например, у меня есть текстовое представление, в котором написано «ВЫ ХОРОШИЙ ИНСТРУКТОР», с которым будет 5 кнопок для оценки, таких как «полностью согласен», «согласен», «нейтрален», «не согласен» и «категорически не согласен».**
[ВЫ ХОРОШИЙ ПРЕПОДАВАТЕЛЬ, ХОРОШО ПРЕПОДАЕТЕ В КЛАССЕ, МОТИВИРУЕТЕ УЧЕНИКА ХОРОШО УЧИТЬСЯ, ПОНИМАЕТЕ УЧЕНИКА]
Пример, например: Каждая форма оценки в этом массиве будет иметь 5 кнопок, чтобы студент мог оценить своего преподавателя.
lt;?xml version="1.0" encoding="utf-8"?gt; lt;androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" android:id="@ id/drawer_layout" android:layout_gravity="start" tools:context=".User" gt; lt;com.google.android.material.navigation.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:id="@ id/nav_view" app:headerLayout="@layout/nav_header" app:menu="@menu/drawer_menu"/gt; lt;androidx.appcompat.widget.Toolbar android:id="@ id/toolbar" android:layout_width="90dp" android:layout_height="?attr/actionBarSize" android:background="@color/white" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /gt; lt;FrameLayout android:id="@ id/fragmentContainer" android:layout_width="match_parent" android:layout_height="672dp" gt; lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="#F6F0F0" tools:context=".User" gt; lt;RelativeLayout android:id="@ id/header" android:layout_width="match_parent" android:layout_height="70dp" android:background="#802626" android:paddingLeft="15dp"gt; lt;ImageView android:id="@ id/menu_logo" android:layout_width="60dp" android:layout_height="60dp" android:layout_centerVertical="true" android:src="@drawable/ic_menu" /gt; lt;/RelativeLayoutgt; lt;TextView android:id="@ id/select" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@ id/header" android:text="Select: " android:layout_marginTop="10dp" android:layout_marginLeft="10dp" android:textColor="@color/black" android:textSize="24sp" /gt; lt;Spinner android:id="@ id/faculty" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_below="@ id/header" android:layout_marginLeft="20dp" android:layout_marginTop="10dp" android:layout_toRightOf="@ id/select" android:theme="@style/Theme.Design.Light.NoActionBar" android:visibility="visible" /gt; lt;ScrollView android:id="@ id/body" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@ id/faculty" android:layout_marginTop="20dp" android:paddingBottom="80dp" gt; lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:id="@ id/containerTable"gt; lt;LinearLayout android:id="@ id/tableQuestions1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_marginBottom="15dp" android:paddingLeft="10dp"gt; lt;TextView android:id="@ id/question1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:textColor="@color/black" android:textSize="20sp" /gt; lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"gt; lt;androidx.appcompat.widget.AppCompatButton android:id="@ id/xAgree1" android:layout_width="60dp" android:layout_height="40dp" android:layout_below="@ id/question1" android:layout_marginLeft="20dp" android:layout_marginRight="5dp" android:background="#52D15E" android:text="SA" /gt; lt;androidx.appcompat.widget.AppCompatButton android:id="@ id/agree1" android:layout_width="70dp" android:layout_height="40dp" android:layout_below="@ id/question" android:layout_marginRight="5dp" android:layout_toRightOf="@ id/xAgree1" android:background="#6498EF" android:text="A" /gt; lt;androidx.appcompat.widget.AppCompatButton android:id="@ id/neutral1" android:layout_width="70dp" android:layout_height="40dp" android:layout_below="@ id/question1" android:layout_marginRight="5dp" android:layout_toRightOf="@ id/agree1" android:background="#979BA1" android:text="N" /gt; lt;androidx.appcompat.widget.AppCompatButton android:id="@ id/disagree1" android:layout_width="70dp" android:layout_height="40dp" android:layout_below="@ id/question1" android:layout_marginRight="5dp" android:layout_toRightOf="@ id/neutral1" android:background="#DCCC3D" android:text="DA" /gt; lt;androidx.appcompat.widget.AppCompatButton android:id="@ id/xDisagree1" android:layout_width="70dp" android:layout_height="40dp" android:layout_below="@ id/question" android:layout_toRightOf="@ id/disagree" android:background="#DA4545" android:text="SDA" /gt; lt;/LinearLayoutgt; lt;/LinearLayoutgt; lt;/LinearLayoutgt; lt;/ScrollViewgt; lt;Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Submit" android:background="#219EA8" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_alignParentBottom="true" android:layout_marginBottom="6dp" android:id="@ id/btnSubmit" /gt; lt;/RelativeLayoutgt; lt;/FrameLayoutgt; lt;/androidx.drawerlayout.widget.DrawerLayoutgt;
private void getQuestion() { String url = getString(R.string.api_server) "/question"; ArrayListlt;Stringgt; initQuestion = new ArrayListlt;gt;(); new Thread(new Runnable() { @Override public void run() { Http http = new Http(User.this, url); http.setToken(true); http.send(); runOnUiThread(new Runnable() { @Override public void run() { Integer code = http.getStatusCode(); if(code == 200){ try { JSONArray response = new JSONArray(http.getResponse()); int length = response.length(); if(length gt; 0 ){ for(int i=0; i lt; response.length(); i ) { JSONObject object = response.getJSONObject(i); String question = object.getString("question"); String lol = question.toUpperCase(); initQuestion.add(lol); // System.out.println(initQuestion); } System.out.println(initQuestion); finalQuestion(initQuestion); }else{ tvQuestion1.setText("No Evaluation Available."); } }catch (JSONException e){ e.printStackTrace(); } } } }); } }).start(); } private void finalQuestion(ArrayListlt;Stringgt; initQuestion) { StringBuilder question = new StringBuilder(); for (int counter = 0; counter lt; initQuestion.size(); counter ) { question.append(initQuestion.get(counter) "n"); } tvQuestion1.setText(question); }