我想为 Spinner 做 if else 声明。我宣布“六月”、“七月”、“八月”、“九月”、“十月”、“十一月”、“十二月”
当我单击“August”时,它会给我 MainActivity.java,否则它会给我 August.java。现在,我的微调器是自动选择的,这意味着,当我加载页面时,它会自动为我选择“六月”。有没有办法让我禁用自动选择?
这是我的代码
String [] months = {
"June",
"July",
"August",
"Septemeber",
"November",
"December",
我的 date.java 的一部分
//SpinnerView
s1 = (Spinner) findViewById(R.id.spinner1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, months);
s1.setAdapter(adapter);
s1.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> arg0,View arg1, int arg2, long arg3) {
int index = s1.getSelectedItemPosition();
//Toast.makeText(getBaseContext(), "You have seleted item :" + months[index] , Toast.LENGTH_SHORT).show();
}
public void onNothingSelected(AdapterView<?>arg0) {}
});
if ( s1.equals("August")) {
startActivity(new Intent(date.this,MainActivity.class));
}
else{
startActivity(new Intent(date.this,august
.class));
}