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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:54:15+00:00 2026-05-14T08:54:15+00:00

I am a rookie to android. I am thinking of implementing a simple calculator

  • 0

I am a rookie to android. I am thinking of implementing a simple calculator in android to get a hold of the basics in android. I want to display a keypad with numbers and mathematical operations and when the user presses the keys the corresponding number is displayed in edit text. I tried using gettext() and updating the contents of edit text but it shows just the contents of pressed button. Also how do I read the contents of button so as to do mathematical operations in code? Any help would be much appreciated.

regards,

Primal

  • 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-14T08:54:16+00:00Added an answer on May 14, 2026 at 8:54 am

    Treating the caption of the button as the actual data is something that is pretty much only acceptable practice when you’re doing the digit-buttons in a calculator, so I don’t know if that holds for ‘android basics’ 😉

    Regardless;

    You’re stating you want to display the corresponding number, when the user presses a key (button?). And then you say getText just shows you the content of the pressed button… Is that not exactly what you’re asking for? You might need to provide a bit of code and show us what’s not working the way you intended. But if a button has the text ‘8’, and you want to treat that as an eight in mathematical operations, you need to parse it:

    Integer myNumber = Integer.parse(myButton.getText());
    

    …which will of course throw an exception if the text of myButton does not resolve to an integer.

    EDIT, AS OF COMMENT

    From the explanation of your problem you gave in your comment, yes, setText() resets the text entirely to the value it’s being passed, but you can use a combination of that and getText() if you just want to append something to the current value:

    myEditText.setText( myEditText.getText() + " " + myButton.getText() );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm totally rookie as to PHP. I want to write a PHP script in
This should be really simple but I'm a javascript/jQuery rookie, so here we go:
I am a fairly rookie programmer who is trying to learn the basics of
I'm a rookie trying to search a text file for some serial numbers. I'm
A rookie here. I have this specific issue in implementing Model View Presenter Pattern
Possible Duplicate: Android HttpClient and HTTPS I want to write app on Android which
This might be a really rookie question, but I'm writing an Android app that
Rookie question, I think. I'm just trying to replicate this: http://rpubs.com/gallery/googleVis Open a new
Rookie C++ Programmer here again I'm using VC++ VS2008 and making an attempt at
This is obviously a rookie question about Adobe technologies, but I am seeking a

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.