RadioGroup в TableLayout

Интерфейс, диалоги, темы, стили, меню
Закрыто
SES
Сообщения: 13
Зарегистрирован: 12 фев 2015, 17:56

RadioGroup в TableLayout

Сообщение SES » 13 фев 2015, 12:11

Доброго времени суток!

Подскажите, пожалуйста, как в TableLayout горизонтально объединить RadioButton в RadioGroup.
Вопросы и ответы могут быть разной длинны.
[syntax=xml]<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"
android:background="#eeeeee"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".Main">

<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Отв1"
android:id="@+id/tVA1"
android:layout_gravity="center"
android:layout_column="1" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Отв2"
android:id="@+id/tVA2"
android:layout_gravity="center"
android:layout_column="2" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Отв3"
android:id="@+id/tVA3"
android:layout_gravity="center"
android:layout_column="3" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Отв4"
android:id="@+id/tVA4"
android:layout_gravity="center"
android:layout_column="4" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dddddd"
android:padding="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Вопрос 1"
android:id="@+id/tVQ1"
android:layout_gravity="center_vertical"
android:layout_column="0" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rB11"
android:layout_column="1"
android:layout_gravity="center"
android:checked="false" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rB12"
android:layout_column="2"
android:layout_gravity="center"
android:checked="false" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rB13"
android:layout_column="3"
android:layout_gravity="center"
android:checked="false" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rB14"
android:layout_column="4"
android:layout_gravity="center"
android:checked="false" />

</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Вопрос 2"
android:id="@+id/tVQ2"
android:layout_gravity="center_vertical"
android:layout_column="0" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rB21"
android:layout_column="1"
android:layout_gravity="center"
android:checked="false" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rB22"
android:layout_column="2"
android:layout_gravity="center"
android:checked="false" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rB23"
android:layout_column="3"
android:layout_gravity="center"
android:checked="false" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rB24"
android:layout_column="4"
android:layout_gravity="center"
android:checked="false" />

</TableRow>

</TableLayout>[/syntax]
Заранее благодарен, Евнегий.
Вложения
anq001.png
anq001.png (12.37 КБ) 2703 просмотра

Аватара пользователя
doter.ua
Сообщения: 1106
Зарегистрирован: 23 ноя 2013, 16:08
Откуда: Ukraine

Re: RadioGroup в TableLayout

Сообщение doter.ua » 13 фев 2015, 12:50

Семь раз отмерь - поставь студию.
Эклипс не студия, ошибка вылетит - не исправишь.
Скажи мне кто твой друг, и оба поставили студию.
Студия - свет, а эклипс - тьма.

SES
Сообщения: 13
Зарегистрирован: 12 фев 2015, 17:56

Re: RadioGroup в TableLayout

Сообщение SES » 13 фев 2015, 14:39

doter.ua писал(а):android:layout_span="2"
http://stackoverflow.com/questions/7212 ... ablelayout
Не вышло.
Что я сделал не так?
[syntax=xml]<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dddddd"
android:padding="5dp" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Вопрос 3 (layout_span)"
android:id="@+id/tVQ3"
android:layout_gravity="center_vertical"
android:layout_column="0" />

<RadioGroup
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_span="4"
android:orientation="horizontal">

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton5"
android:layout_gravity="center"
android:checked="false" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton6"
android:layout_gravity="center"
android:checked="false" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton7"
android:layout_gravity="center"
android:checked="false" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton8"
android:layout_gravity="center"
android:checked="false" />
</RadioGroup>

</TableRow>[/syntax]
Вложения
anq002.png
anq002.png (15.72 КБ) 2698 просмотров

SES
Сообщения: 13
Зарегистрирован: 12 фев 2015, 17:56

Re: RadioGroup в TableLayout

Сообщение SES » 19 фев 2015, 13:17

Спасибо всем, кто откликнулся.
Все получилось, тему можно закрывать.
Вложения
andr.png
andr.png (72.68 КБ) 2684 просмотра

Закрыто