2017-01-18 3 views
0

Я создаю 10 переключателей в одном столбце, но я не знаю, как сделать их в одну группу радио, потому что в моем макете. У меня есть столбец и layout_span.Как сделать переключатель в несколько строк в одном столбце

Например, в первой колонке 1 (Полезность). Я хочу сделать переключатель в одной группе, но если я поставлю еще один переключатель под «Хорошо» (6-7), он должен сделать другую группу радио.

<TableRow android:background="#f2a344"> 
      <TextView 
       android:layout_span="5" 
       android:text="CSP650-PROJECT EXHIBIT AWARD EVALUATION (F11) RUBRIC" 
       android:layout_gravity="center_horizontal"/> 
     </TableRow> 
     <TableRow android:baselineAligned="false" 
      android:background="#fadc1f"> 
      <TextView android:lines="1" 
       android:text="Assessment Criteria" /> 
      <TextView android:text="Excellent(8-10)"/> 
      <TextView android:text="Good(6-7)"/> 
      <TextView android:text="Satisfactory(5)"/> 
      <TextView android:text="Poor(1-4)"/> 
     </TableRow> 

     <TableRow android:background="#cb7ded"> 
      <TextView 
       android:text="1. Usefulness" 

       android:lines="6"/> 

      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_column="1"> 
       <RadioGroup 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal"> 

        <RadioButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="10" 
         android:id="@+id/radio213" /> 

        <RadioButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="9" 
         android:id="@+id/radio214" 
         android:layout_gravity="center_horizontal" /> 
        <RadioButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="8" 
         android:id="@+id/radio215" 
         android:layout_gravity="center_horizontal" /> 
       </RadioGroup> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="-Very useful and innovative." 
        android:id="@+id/textView137" /> 
      </LinearLayout> 
      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_column="1"> 
       <RadioGroup 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal"> 

        <RadioButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="7" 
         android:id="@+id/radio216" 
         android:layout_gravity="center_horizontal" /> 
        <RadioButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="6" 
         android:id="@+id/radio217" 
         android:layout_gravity="center_horizontal" /> 
       </RadioGroup> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="-Useful and show some \n innovative potential." 
        android:id="@+id/textView138" /> 
      </LinearLayout> 
      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_column="1"> 
       <RadioGroup 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal"> 

        <RadioButton 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:text="5" 
         android:id="@+id/radio218" 
         android:layout_gravity="center_horizontal" /> 
       </RadioGroup> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="-Somewhat useful but \n lack innovation." 
        android:id="@+id/textView139" /> 

      </LinearLayout> 
      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_column="1"> 
       <RadioGroup 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal"> 

        <RadioButton 
         android:layout_width="40dp" 
         android:layout_height="40dp" 
         android:text="4" 
         android:id="@+id/radio219" 
         android:layout_gravity="center_horizontal" /> 
        <RadioButton 
         android:layout_width="40dp" 
         android:layout_height="40dp" 
         android:text="3" 
         android:id="@+id/radio220" 
         android:layout_gravity="center_horizontal" /> 
        <RadioButton 
         android:layout_width="40dp" 
         android:layout_height="40dp" 
         android:text="2" 
         android:id="@+id/radio221" 
         android:layout_gravity="center_horizontal" /> 
        <RadioButton 
         android:layout_width="40dp" 
         android:layout_height="40dp" 
         android:text="1" 
         android:id="@+id/radio222" 
         android:layout_gravity="center_horizontal" /> 
       </RadioGroup> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="-Lack usefulness" 
        android:id="@+id/textView140" /> 

      </LinearLayout> 
     </TableRow> 

ответ

0

Попробуйте установить ориентацию Радио групповой

android:orientation="vertical" 

Надеется, что это помогает вам.

+0

я уже попробовать. но это не сработало – syafika

+0

Можете ли вы представить скриншот или некоторый интерфейс, как должен выглядеть ваш пользовательский интерфейс. Это поможет в понимании проблемы точно –

+0

http://imgur.com/a/SIumZ – syafika

0

U может использовать этот формат типа:

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 
<TableRow> 
    <TableLayout 
     android:layout_width="0dip" 
     android:layout_height="fill_parent" 
     android:layout_weight="2"> 
     <TableRow 
      android:layout_width="0dip" 
      android:layout_height="0dip" 
      android:layout_weight="2"> 
      <View 
       android:layout_width="0dip" 
       android:layout_height="fill_parent" 
       android:layout_margin="5dip" 
       android:layout_weight="1" 
       android:background="#fff"></View> 
      <View 
       android:layout_width="0dip" 
       android:layout_height="fill_parent" 
       android:layout_margin="5dip" 
       android:layout_weight="1" 
       android:background="#eee"></View> 
     </TableRow> 
     <TableRow 
      android:layout_width="0dip" 
      android:layout_height="0dip" 
      android:layout_weight="2"> 
      <View 
       android:layout_width="0dip" 
       android:layout_height="fill_parent" 
       android:layout_margin="5dip" 
       android:layout_weight="1" 
       android:background="#eee"></View> 
      <View 
       android:layout_width="0dip" 
       android:layout_height="fill_parent" 
       android:layout_margin="5dip" 
       android:layout_weight="1" 
       android:background="#fff"></View> 
     </TableRow> 
    </TableLayout> 
    <TableLayout 
     android:layout_width="0dip" 
     android:layout_height="fill_parent" 
     android:layout_weight="1"> 
     <TableRow> 
      <View 
       android:layout_width="0dip" 
       android:layout_height="fill_parent" 
       android:layout_weight="1" 
       android:background="#bbb"></View> 
     </TableRow> 
    </TableLayout> 
</TableRow> 
</TableLayout> 
+0

хорошо, я попробую. благодарю вас – syafika

+0

u может поставить ваш переключатель в это означает –

0

Вы можете сделать это с помощью кода Java

RadioGroup rg = new RadioGroup(this); //create the RadioGroup 
RadioButton rb1 = findViewById(R.id.rb1); 
RadioButton rb2 = findViewById(R.id.rb2); 
RadioButton rb3 = findViewById(R.id.rb3); 
RadioButton rb4 = findViewById(R.id.rb4); 
rg.addView(rb1); 
rg.addView(rb2); 
rg.addView(rb3); 
rg.addView(rb4); 
Смежные вопросы