Радиокнопка исчезла после размещения внутри радиогруппы в линейной компоновке

Я хочу, чтобы две радиокнопки располагались рядом, поэтому использовалось горизонтальное расположение, но одна проблема, с которой я столкнулся, заключается в том, что обе радиокнопки выбираются вместо нормального поведения, когда любой радиокнопка должна быть выбрана. Итак, я использовал radio group внутри linear layout horizontal, но на удивление все переключатели исчезли.

<LinearLayout
        android:layout_width="150dip"
        android:layout_height="22dip"
        android:background="@color/silver"
        android:orientation="horizontal" >

       <RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="150dip"
        android:layout_height="22dip"
        android:background="@color/silver" >

       <RadioButton
            android:id="@+id/radioButton1"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="/share" 
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <RadioButton
            android:id="@+id/radioButton2"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="/value" 
            android:textAppearance="?android:attr/textAppearanceSmall" />

        </RadioGroup>

       </LinearLayout>

введите здесь описание изображения

Мне нужно, чтобы переключатель был ниже abc.

Полный XML

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:background="@color/dark_snuff"
        android:orientation="horizontal" >

        <LinearLayout
        android:layout_width="150dip"
        android:layout_height="45dp"
        android:background="@color/silver"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView8"
            android:layout_width="150dp"
            android:layout_height="23dip"
            android:background="@color/silver"
            android:text=" Brokerage"
            android:typeface="serif"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <LinearLayout
        android:layout_width="150dip"
        android:layout_height="22dip"
        android:background="@color/silver"
        android:orientation="horizontal" >

       <RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="150dip"
        android:layout_height="22dip"
        android:background="@color/silver" >

       <RadioButton
            android:id="@+id/radioButton1"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="/share" 
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <RadioButton
            android:id="@+id/radioButton2"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="/value" 
            android:textAppearance="?android:attr/textAppearanceSmall" />

        </RadioGroup>

       </LinearLayout>

        </LinearLayout>

        <EditText
            android:id="@+id/editText8"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:textColor="@color/white"
            android:background="@drawable/backgroud"
            android:gravity="center"
            android:typeface="serif"
            android:ems="10"
            android:inputType="numberDecimal"
            android:text="0.0" >

            <requestFocus />
        </EditText>

        <EditText
            android:id="@+id/editText9"
            android:layout_width="0dip"
            android:layout_height="match_parent"
            android:layout_weight="1.00"
            android:gravity="center"
            android:textColor="@color/white"
            android:background="@drawable/backgroud"
            android:typeface="serif"
            android:ems="10"
            android:inputType="numberDecimal"
            android:text="0.0" />

    </LinearLayout>

person Siva    schedule 08.10.2014    source источник
comment
RadioGroup extends LinearLayout поэтому в LL не должно быть необходимости, если он содержит только RG. Кроме того, покажите остальную часть вашего xml.   -  person codeMagic    schedule 08.10.2014
comment
@codeMagic спасибо за ваш ответ.. пожалуйста, найдите мой XML-код.. если я удалю Radio Group, я смогу увидеть переключатели   -  person Siva    schedule 08.10.2014
comment
Что если оставить RG и убрать LL?   -  person codeMagic    schedule 08.10.2014
comment
@codeMagic Если я оставлю только RG, тогда также будет тот же переключатель, который все равно исчезнет   -  person Siva    schedule 08.10.2014
comment
@codeMagic Спасибо за вашу помощь, я нашел ответ .. Мне не хватает параметра orientation в группе радио   -  person Siva    schedule 08.10.2014


Ответы (1)


Наконец-то я понял ответ, так как мне не хватает параметра Orientation для radio group....

Добавил этот параметр android:orientation="horizontal"

Теперь XML

<RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="150dip"
        android:layout_height="22dip"
        android:orientation="horizontal"
        android:background="@color/silver" > 

Теперь нет необходимости в linear layout horizontal

person Siva    schedule 08.10.2014
comment
Я рад, что это работает, но должно быть что-то еще происходит. Как будто это родитель. LinearLayout, в этом атрибуте нет необходимости, так как его значение по умолчанию равно horizontal. - person codeMagic; 08.10.2014
comment
@codeMagic Мне любопытно узнать, как мы можем узнать исходный код или что-то более глубокое в Android ... например, то, что вы сказали Radio Group extends Linear Layout, которого я не знаю ... не могли бы вы поделиться со мной, как я могу изучить эти концепции. . извините, если это преждевременный вопрос... Также извините, если беспокою вас .. спасибо - person Siva; 09.10.2014
comment
Нет проблемы. Глядя в документы вы можете увидеть список наследования классов под именем класса. Вот где вы можете увидеть RadioGroup extends LinearLayout. Вам не нужен источник для этого. Вы должны иметь возможность найти исходный код в своем SDK, но вы также можете загрузить исходный код через документы. Его также можно найти на github и зеркалировать в других местах. - person codeMagic; 09.10.2014
comment
@codeMagic Спасибо за ваш ответ, я начну учиться с вашего предложения... - person Siva; 09.10.2014