3

I'm using Android Studio and I have an app with a radio group of 4 buttons in my project, wich are used to pick an answer from my database. The buttons are invisible on the device but can still click them as they show up a green color when clicked. Also the text is not showing for each answer but the question text in the textview above the radio buttons is showing! Very confusing. Has anyone ran into this issue and know how to resolve it? Here's a copy of my xml layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:gravity="center_horizontal"
    android:background="@drawable/background">

    <LinearLayout 
        android:orientation="horizontal"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:paddingTop="15dip" 
        android:paddingBottom="15dip"
        android:gravity="center_horizontal">

        <ImageView android:id="@+id/logo" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:src="@drawable/logo2" />

    </LinearLayout>

    <LinearLayout android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingTop="5dip"
        android:paddingBottom="5dip"
        android:gravity="center_horizontal">

        <RadioGroup android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:orientation="vertical"
            android:id="@+id/group1">

            <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content" 
                android:textColor="#ffffff"
                android:textStyle="bold" 
                android:id="@+id/question"/>

            <RadioButton android:checked="false" android:id="@+id/answer1"
                />

            <RadioButton android:checked="false" android:id="@+id/answer2"
                />

            <RadioButton android:checked="false" android:id="@+id/answer3"
                />

            <RadioButton android:checked="false" android:id="@+id/answer4"
                />

        </RadioGroup>

    </LinearLayout>


    <Button android:text="Next"
        android:id="@+id/nextBtn"
        android:layout_width="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_height="wrap_content"
        android:background="@drawable/button_selector"
        android:paddingTop="5dip"
        android:paddingBottom="5dip"
        android:textColor="#ffffff"
        android:layout_gravity="center_horizontal" />

</LinearLayout>
james
  • 157
  • 1
  • 2
  • 11
  • I can not find where you changed the text color of the radio buttons. You changed the text color of your textview to white... Maybe you have a black bavkground with blavk text and black icons on it? – AlbAtNf Oct 09 '15 at 18:03
  • Try to change your main view background, maybe it have the same color as your text and RadioButton background. This is why they look invisible for you. – Rami Oct 09 '15 at 18:03
  • i have tired changing background, the text is white on a black background, the text above in the textview displays fine but just the radio group is invisible – james Oct 09 '15 at 18:13
  • just tried and its the same problem – james Oct 09 '15 at 18:24
  • What does your **Run code snippet** button do? It shows nothing. – IgorGanapolsky Sep 14 '16 at 16:55

1 Answers1

2

Just replace your radio buttons of radio group with this,

<RadioButton android:checked="false" android:id="@+id/answer1"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="text 1"
            />

        <RadioButton android:checked="false" android:id="@+id/answer2"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="text 2"
            />

        <RadioButton android:checked="false" android:id="@+id/answer3"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="text 3"
            />

        <RadioButton android:checked="false" android:id="@+id/answer4"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="text 4"
            />

It will work :)

Hardik Chauhan
  • 2,750
  • 15
  • 30
  • same problem unfortunatly :-( its a real puzzle, the radio group is supposed to display the answers from my database, they did do originally, i figured it cant be the database as the questions are showing fine! just the radiogroup invisible along with the answers – james Oct 09 '15 at 18:39
  • changed the text color after your edit to each button and the answers are displaying now but the radio buttons invisible – james Oct 09 '15 at 18:43
  • So the thumb of radio button inside radio group is not displaying right?? – Hardik Chauhan Oct 09 '15 at 18:46
  • yea, its there because i press the screen and it appears as a green color and then vanishes again – james Oct 09 '15 at 18:48
  • its a selection check button if that helps – james Oct 09 '15 at 18:50
  • Hi i have added the same layout with static text and background. And it was working fine means i can see question, answers and all the radio buttons. Are you doing any design chagnes programetically? – Hardik Chauhan Oct 09 '15 at 19:23
  • hi, yes i was just looking into that and it seems i have 3 linear layouts on the activity! and have changed this now and the buttons do display, wouldnt of done it without your help though so thank you very much for your time and help – james Oct 09 '15 at 19:36
  • Where are you actually declaring a **RadioGroup**?? I don't see it in your code. – IgorGanapolsky Sep 14 '16 at 16:56