它接触像抛出异常的部分是onclick listerner之后的部分,因为如果我评论它应用程序将运行良好(虽然不起作用)
public class MyActivity extends Activity {
int poundtwenty;
int poundten;
int poundfive;
int poundtwo;
int poundone;
int tenpences;
int twentypences;
int fiftypences;
int £20out;
int £10out;
int £5out;
int £2out;
int £1out;
double fiftyout;
double twentyout;
double tenout;
double Total;
EditText in£20;
EditText in£10;
EditText in£5;
EditText in£2;
EditText in£1;
EditText in50;
EditText in20;
EditText in10;
Button Go;
TextView outTotal;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
in£20 = (EditText) findViewById(R.id.poundtwentyin);
in£10 = (EditText) findViewById(R.id.poundtenin);
in£5 = (EditText) findViewById(R.id.poundfivein);
in£2 = (EditText) findViewById(R.id.poundtwoin);
in£1 = (EditText) findViewById(R.id.poundonein);
in50 = (EditText) findViewById(R.id.fiftyin);
in20 = (EditText) findViewById(R.id.twentyin);
in10 = (EditText) findViewById(R.id.tenin);
Go = (Button) findViewById(R.id.go);
Go.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int poundtwenty = Integer.parseInt(in£20.getText().toString());
int poundten = Integer.parseInt(in£10.getText().toString());
int poundfive = Integer.parseInt(in£5.getText().toString());
int poundtwo = Integer.parseInt(in£2.getText().toString());
int poundone = Integer.parseInt(in£1.getText().toString());
int fiftypences = Integer.parseInt(in50.getText().toString());
int twentypences = Integer.parseInt(in20.getText().toString());
int tenpences = Integer.parseInt(in10.getText().toString());
double fiftyout = (double) fiftypences/2;
double twentyout = (double) twentypences/5;
double tenout = (double) tenpences/10;
double Total = (double) tenout + (double) twentyout + (double) fiftyout + (double) poundone
+ (double) poundtwo*2 + (double) poundfive*5 + (double) poundten*10 + (double) poundtwenty*20;
}
});
}
}
任何帮助将不胜感激
stacktrace(无法在此处正确格式化) https://drive.google.com/file/d/0B-uBh91OVJUycXlFMFVFTUYwbjQ/edit?usp=sharing