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

  • Home
  • SEARCH
  • 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 6911543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:58:13+00:00 2026-05-27T08:58:13+00:00

I want to make a simple calculator My code is below: package som.dev.android.calc; import

  • 0

I want to make a simple calculator My code is below:

package som.dev.android.calc;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class CalcApp extends Activity {
    /** Called when the activity is first created. */
    Button addValues, subValues, equalsValue;
    EditText inputValue;

    int inputNum = 0;
    public int value1;
    public int value2;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        // initializing Views
        inputValue = (EditText) findViewById(R.id.editText1);
        addValues = (Button) findViewById(R.id.addBtn);
        subValues = (Button) findViewById(R.id.subBtn);
        equalsValue = (Button) findViewById(R.id.equalsBtn);

        // adding onClick Listeners
        addValues.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                pressed = true;
                value1 = Integer.parseInt(inputValue.getText().toString());
                inputValue.setText("");
            }
        });

        equalsValue.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                value2 = Integer.parseInt(inputValue.getText().toString());
                int result = value1+value2;

                inputValue.setText(result);// There an exception occurs....
            }
        });
    }
}

But it does not sets result to Edittext in my app and an exception occurs and message comes Unfortunately app is colsed some thing like that so please any one tell me the solution of this problem

  • 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-27T08:58:13+00:00Added an answer on May 27, 2026 at 8:58 am

    use this inputValue.setText(""+result);instead of inputValue.setText(result);// There an exception occurs....

    just conversion integer into string

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am new to Android, and am building a simple calculator app. I want to
I want to make a simple app, where a UIWebView with custom content will
I want to make a really simple iphone app: one screen with a single
I'm, trying to make a simple 3D game for Android, and I want to
I want to be a complete nerd and make a very simple binary calculator.
I'm coding a simple calculator and I want to make an unique function for
I'm familiar with core data but want to make a simple app that calculates
Basically I want to make simple toggle program (that will be mapped to some
I need information about making installation packages for Linux. I want to make simple
I want to make a simple game: 2d, single-player, without tons of animations and

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.