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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:42:52+00:00 2026-06-12T08:42:52+00:00

I have created one simple application using Android but this application crashes when I

  • 0

I have created one simple application using Android but this application crashes when I click on any of the View.Can you please help on below code of MainActivity.java:

public class CalculatorMainActivity extends Activity implements OnClickListener{
int a3 =0, a1=0,a2 =0;
 Button b1,b2;
  EditText t1,t2;
 TextView v1;
 @Override
 public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_calculator_main);

     b1=(Button) findViewById(R.id.mul);
     b2=(Button) findViewById(R.id.sum);
     t1 = (EditText) findViewById(R.id.editText1);
     t2 = (EditText) findViewById(R.id.editText2);
     v1 = (TextView) findViewById(R.id.text1);

     b1.setOnClickListener(this);
     b2.setOnClickListener(this);
     t1.setOnClickListener(this);
     t2.setOnClickListener(this);
     v1.setOnClickListener(this);  

}

 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_calculator_main, menu);
    return true;
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

    String s1 = t1.getText().toString();

    a1 = Integer.parseInt(s1);

    String s2 = t2.getText().toString();
    a2 = Integer.parseInt(s2);

    if (v == b1)
    a3 = a1 + a2;
    v1.setText(a3.toString());  
    if (v == b2)
    a3 = a1 * a2; 
    v1.setText(a3.toString());

}
 }

It would be very helpful if you can give some solution to this Error.

  • 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-12T08:42:53+00:00Added an answer on June 12, 2026 at 8:42 am

    It crashes here :

    v1.setText(a3.toString());
    

    because you don’t have {} around your if action, and a3 is not defined.

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

Sidebar

Related Questions

I have created a simple text chat application for android device using flex 4
Using xlwDotNet, I have created a simple function which returns one number. Sometimes, something
I have created a simple Hello World Application using Flash Builder Burrito SDK. I
I'm writing a simple application for Android. I have 2 tables - one called
I have used facebook application for one of my android application. But i need
I am a bit confused. I have created a simple form with a one
I have created one service in my grails application. in that service 25 methods
i have created one image but problem is that when i save image from
I have created one multiplication of complex function using prototype in java-script function ComplexNumber(real,imaginary)
I am trying to develop one simple application using Java, Flex and Blazeds. I

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.