Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » unable to lunch Calculator on AVD
unable to lunch Calculator on AVD [message #1454788] Tue, 28 October 2014 19:30 Go to next message
Eriks Vizums is currently offline Eriks VizumsFriend
Messages: 4
Registered: October 2014
Junior Member
Hello, I have a problem with this calculator code,because I think i messed up with library imports.



package eriksdas.kalkulators;

import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.Button;
import android.widget.TextView;
import android.view.MenuItem;
import android.widget.*;
import android.view.View;
import android.view.View.OnClickListener;
import android.util.Log;



public class MainActivity extends Activity {
EditText one,two;
Button plus, minus, multiply,divide;
TextView showres;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

one = (EditText)findViewById(R.id.editText1);
two = (EditText)findViewById(R.id.editText2);
plus = (Button)findViewById(R.id.button1);
minus = (Button)findViewById(R.id.button2);
multiply = (Button)findViewById(R.id.button3);
divide = (Button)findViewById(R.id.button4);
showres = (TextView)findViewById(R.id.TextView3);

plus.setOnClickListener((new View.OnClickListener() {

@Override
public void OnClick(View arg0) {
// 1000 Auto-generated method stub
try{
int n1 = Integer.parseInt(one.getText().toString());
int n2 = Integer.parseInt(two.getText().toString());
int sum = n1+n2;
showres.setText(sum);

}
catch(exception e){

}
}

}));


minus.setOnClickListener((new View.OnClickListener() {

@Override
public void OnClick(View arg0) {
// 1000 Auto-generated method stub
try{
int n1 = Integer.parseInt(one.getText().toString());
int n2 = Integer.parseInt(two.getText().toString());
int sum = n1-n2;
showres.setText(sum);

}
catch(exception e){

}
}

}));
multiply.setOnClickListener((new View.OnClickListener() {

@Override
public void OnClick(View arg0) {
// 1000 Auto-generated method stub
try{
int n1 = Integer.parseInt(one.getText().toString());
int n2 = Integer.parseInt(two.getText().toString());
int sum = n1*n2;
showres.setText(sum);

}
catch(exception e){

}
}

}));

divide.setOnClickListener((new View.OnClickListener() {

@Override
public void OnClick(View arg0) {
// 1000 Auto-generated method stub
try{
int n1 = Integer.parseInt(one.getText().toString());
int n2 = Integer.parseInt(two.getText().toString());
int sum = n1/n2;
showres.setText(sum);

}
catch(exception e){

}
}

}));
};



@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

[Updated on: Tue, 28 October 2014 19:33]

Report message to a moderator

Re: unable to lunch Calculator on AVD [message #1456806 is a reply to message #1454788] Thu, 30 October 2014 18:59 Go to previous messageGo to next message
Jorgesys sys is currently offline Jorgesys sysFriend
Messages: 8
Registered: October 2014
Junior Member
What kind of problem, any message displayed in LogCat or Console?
Re: unable to lunch Calculator on AVD [message #1459649 is a reply to message #1456806] Sun, 02 November 2014 19:30 Go to previous messageGo to next message
Eriks Vizums is currently offline Eriks VizumsFriend
Messages: 4
Registered: October 2014
Junior Member
Your project contains errors
Re: unable to lunch Calculator on AVD [message #1460184 is a reply to message #1456806] Mon, 03 November 2014 09:32 Go to previous message
Eriks Vizums is currently offline Eriks VizumsFriend
Messages: 4
Registered: October 2014
Junior Member
I got this errors
  • Attachment: 31.JPG
    (Size: 117.90KB, Downloaded 167 times)
Previous Topic:Eclipse not even starting up
Next Topic:Using JRE 1.8 settings, but JRE remains at 1.4 with compliance 1.7
Goto Forum:
  


Current Time: Fri Apr 26 08:05:56 GMT 2024

Powered by FUDForum. Page generated in 0.03593 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top