加载微调器后,我想获取微调器中设置的微调器值
我知道如何获取选定的值,但是第一次加载是在第一次加载时及时获取空值我想在第一次加载时获取选定的值
微调部分
ArrayAdapter<String>spinnertimeadapter= new ArrayAdapter<String>(AirportChekActivity.this, android.R.layout.simple_spinner_item,flighttime);
spinnertimeadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
timespinner.setAdapter(spinnertimeadapter);
String time;
timespinner.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
String timeselected=timespinner.getSelectedItem().toString();
Calendar now = Calendar.getInstance();
hour=now.get(Calendar.HOUR_OF_DAY);
Log.e("hourrr","-->"+hour);
if(hour>=0 && hour<=2)
{
timespinner.setSelection(0);
}
else if(hour>=3 && hour<=5)
{
timespinner.setSelection(1);
}
else if(hour>=6 && hour<=8)
{
timespinner.setSelection(2);
}
else if(hour>=9 && hour<=11)
{
timespinner.setSelection(3);
}
else if(hour>=12 && hour<=14)
{
timespinner.setSelection(4);
}
else if(hour>=15 && hour<=17)
{
timespinner.setSelection(5);
}
else if(hour>=18 && hour<=21)
{
timespinner.setSelection(6);
}
else if(hour>=22 && hour<=24)
{
timespinner.setSelection(7);
}
stime=timespinner.getSelectedItem().toString();
if(timeselected.equals("12:00AM To 3:00AM"))
{
time="0";
}
else if(timeselected.equals("3:00AM To 6:00AM"))
{
time="3";
}
else if(timeselected.equals("6:00AM To 9:00AM"))
{
time="6";
}
else if(timeselected.equals("9:00AM To 12:00PM"))
{
time="9";
}
else if(timeselected.equals("12:00PM To 3:00PM"))
{
time="12";
}
else if(timeselected.equals("3:00PM To 6:00PM"))
{
time="15";
}
else if(timeselected.equals("6:00PM To 9:00PM"))
{
time="18";
}
else if(timeselected.equals("9:00PM To 12:00AM"))
{
time="21";
}
}
public void onNothingSelected(AdapterView<?> arg0) {
}
}); // time spinner complete