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 9012997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:08:32+00:00 2026-06-16T03:08:32+00:00

I am new to Android programming and so kingly pardon me if this question

  • 0

I am new to Android programming and so kingly pardon me if this question sounds stupid. I am developing a Calculator for Android. So I have around 20 buttons and a text field. Whenever a button is pressed I update the text field so that the user knows what he has typed.

However when I update the textfield the application is crashing.

updateExpression is the method that is called when any button is pressed.

  public void updateExpression (View v)
    {
      Log.d("string", "updateExpression Called");
      EditText text = (EditText) findViewById(R.id.name);
      text.setText("HELLO EVERYONE");
    }

The .xml file of the buttons is:

<Button
    android:id="@+id/Button03"
    android:layout_width="70dp"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/name"
    android:layout_below="@+id/name"
    android:onClick="updateExpression"
    android:text="C" />
// goes on for 20 buttons with different ids and text

<TextView  
    android:id="@+id/name"
    android:layout_width="fill_parent" 
    android:text="@string/edit_message" 
    android:layout_height="33dp" 
    android:textColor="@color/opaque_red"/>
</RelativeLayout>

Finally the logcat has the string data “updateExpression Called”. However immediately after that it crashes. The error has tag AndroidRuntime Fatal Exception main. There are many more errors after this. A relevant one (according to me is)

Caused by: java.lang.classCatException: android.widget.TextView
cannot be cast into android.widget.EditText

Kindly help.

Thank you.

  • 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-06-16T03:08:33+00:00Added an answer on June 16, 2026 at 3:08 am

    You are trying to cast a TextView into an EditText, like the error says. These are two seperate classes.

    EditText text = (EditText) findViewById(R.id.name); 
    

    should be

    TextView text = (TextView) findViewById(R.id.name); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Android programming and so kingly pardon me if this question
I'm new to android programming and i have a question I'm developing an alarm
I'm fairly new to Android programming, so this may be a simple question, but
I'm new to Android programming and trying to wrap my head around this just
I am new to android programming and so please pardon if the question looks
I am new to android programming and i am trying to develop this app
Hi I am completely new to Android programming and the question I am asking
i am new to android programming.i looking to make a question and answer application.in
I am new to android programming and it's been some years since I have
I am new to Android programming. I have installed the Eclipse and Android SDK.

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.