i am doing a if else android coding but it seen that the code don't take data string from selection which is a "textview" and match it to my pre define in the condition of the if else. i wonder is it my coding is wrong? below is my codes.
private static final String[] items={"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "R"};
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
Fabric.with(this, new Crashlytics());
setContentView(R.layout.activity_main);
selection=(TextView)findViewById(R.id.text0);
Spinner spin=(Spinner)findViewById(R.id.spinner0);
result=(TextView)findViewById(R.id.result);
spin.setOnItemSelectedListener(this);
ArrayAdapter<String> aa=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, items);
aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spin.setAdapter(aa);
result.setText("");
if (selection.equals(a)){
int aaa = (1*100);
result.setText(String.valueOf(aaa));
}
else if (selection.equals("1")){
int aaa = (2*10);
result.setText(aaa + "");
}
else if (selection.equals("2")){
int aaa = (3*1);
result.setText(String.valueOf(aaa));
}
else if (bb.equals("R")){
result.setText(".");
}
}
Aucun commentaire:
Enregistrer un commentaire