Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6175505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:56:11+00:00 2026-05-23T23:56:11+00:00

I get the error (see picture) I can’t figure out what going on. It

  • 0

I get the error (see picture) enter image description here

I can’t figure out what going on. It literally say that my RadioGroup cannot be cast to TextView ? but why ? R.id.myMessage is not a RadioButtom !

Activity

public class Ch7_JoshRadioGroup extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final TextView myMessage = (TextView) findViewById(R.id.myMessage);

        // Gestion du bouton "Hello, Joshua"
        Button myButton = (Button) findViewById(R.id.myButton);

        myButton.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View v) {
                // View est un type générale
                // v est le bouton dans ce contexte-ci
                //Button thisOne = (Button) v;
                //thisOne.setText("You pushed this button!");

                // Envoi un toast d'une longue durée lorsque le bouton est appuyé
                Toast.makeText(Ch7_JoshRadioGroup.this, "test", Toast.LENGTH_LONG); 
            }
        });
    }
}

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"
    >

<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:id="@+id/myMessage"
    />

<Button 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello_joshua"
    android:id="@+id/myButton"
    />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:orientation="horizontal">

    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:background="#ff0000"
        android:textColor="#000000"
        android:text="red"
    />

    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:background="#00ff00"
        android:textColor="#000000"
        android:text="green"
    />

    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:gravity="center"
        android:background="#0000ff"
        android:textColor="#000000"
        android:text="blue"
    />
</LinearLayout>

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

    <RadioButton
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginLeft="35dp"
        android:layout_weight="1"
        android:id="@+id/myRadioButtonRed"
     />

    <RadioButton
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginLeft="35dp"
        android:layout_weight="1"
        android:id="@+id/myRadioButtonGreen"
     />

     <RadioButton
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginLeft="35dp"
        android:layout_weight="1"
        android:id="@+id/myRadioButtonBlue"
     />

</RadioGroup>

</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:56:12+00:00Added an answer on May 23, 2026 at 11:56 pm

    Delete the in your xml. IF you are NOT using.

    I assumed you want to set the text of the button

    Button myButton = (Button) findViewById(R.id.myButton);

        myButton.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View v) {
                myButton.seText("You pushed this button");
    
                // Envoi un toast d'une longue durée lorsque le bouton est appuyé
                Toast.makeText(Ch7_JoshRadioGroup.this, "test", Toast.LENGTH_LONG); 
            }
    
       }
    

    When do this, try Clean-ing your project Project -> Clean select the project and hit OK.

    Edit: Your xml should look like this if you dont need the RadioGroup

    <?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"
        >
    
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        android:id="@+id/myMessage"
        />
    
    <Button 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello_joshua"
        android:id="@+id/myButton"
        />
    
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:orientation="horizontal">
    
        <TextView 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:background="#ff0000"
            android:textColor="#000000"
            android:text="red"
        />
    
        <TextView 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:background="#00ff00"
            android:textColor="#000000"
            android:text="green"
        />
    
        <TextView 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:gravity="center"
            android:background="#0000ff"
            android:textColor="#000000"
            android:text="blue"
        />
    </LinearLayout>
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The error I get is Xcode saying 3 things are un-declared (see below picture)
I see that many people get this error, but their situations all appear a
I get this error all the time. And as I can see, there are
See also SO 1664677 I get this error 2: Syntax error: ( unexpected when
I get a crazy error and I am unable to see why it happens.
I can't get the code below to compile (see errors). Advice on correction would
Problem: I'm getting a thrown error from javax.net.ssl.SSLHandshakeException (see attached picture) Is it possible
I get error: ORA-06575: Package or function GET_CONC_NAMES is in an invalid state When
Why do I get error in this code?Even if i do not link but
Why I get error with this query on my live server but not on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.