• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Times two values and display result

hello,

im just getting use to java and android, I'm building an app which allows the user to enter two values then * them both and displays the result.

below is the onCreate method which inside I register a click event where the time multiply is taking place.

[HIGH]
TextView DisplayText;
EditText EnteredText, EnteredTimesText;
int r, eText, eTimesText;

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.button2page);

DisplayText = (TextView) findViewById(R.id.button2TextView);
DisplayText.setText("Calculations");

EnteredText = (EditText) findViewById(R.id.button2EditText);
EnteredTimesText = (EditText) findViewById(R.id.button2EditTextTimes);

Button btnGen = (Button) findViewById(R.id.btnCalculations);
btnGen.setOnClickListener(new View.OnClickListener() {

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

//DisplayText.setText(EnteredText.getText());

eText = Integer.parseInt(EnteredText.getText().toString());
eTimesText = Integer.parseInt(EnteredTimesText.getText().toString());

r = eText * eTimesText;


DisplayText.setText(r);

}
});

}
[/HIGH]

but it keeps erroring can anyone see what im doing wrong here? please bare in mind I've only been doing android for a two days.

thank you for your time
 
Back
Top Bottom