I am trying to take numbers from three EditText boxes that the user fills in, then through some simple math and the user pressing a button, there needs to be an answer through a textView. Also whenever I launch this app on the emulator it says that it needs to Force close once I click on the button to go to this layout and code. Here is the code:
package com.app.one;
import com.app.one.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class monthlyp extends Activity {
int x = 10;
int y= 10;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.monthlyp);
final TextView input = (TextView) findViewById(R.id.editone);
final Button btn = (Button) findViewById(R.id.equals);
final EditText textView13 = (EditText) findViewById(R.id.textView13);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
y = Integer.parseInt(input.getText().toString());
textView13.setText(String.valueOf(y));
}
});
}
}
I know it only has one EditText area but that’s because I need help adding two more and being able to use them as integers to add/subtract/divide/multiply. The xml has all three edittext boxes and an equals button that will solve what is entered. Thanks for the help and please ask me if you need any more information.
You say that input is a textview
then you got the integer value of that textview
I suggest that’s not what you intended