I create customized spinner for my application. I can get the selected spinner item and i can display it too. But I'm not able to reach my if condition within my spinner's onItemSelected() . I wasn't able to check my conditions within spinner. Where did I make a mistake ? can anybody tell me? And how can i resolve this? Thanks in advance.
问问题
606 次
1 回答
0
Just try like this . The if condition will works within spinner onItemSelected() . http://pastie.org/5452818
@Override
public void onItemSelected(AdapterView<?> parent, View v, int position,long id)
{
spinner_value = parent.getSelectedItem().toString();
Log.i("spinner_value", ".."+spinner_value);
if(parent.getItemAtPosition(position).equals("January"))
{
Toast.makeText(this, "Success",Toast.LENGTH_SHORT).show();
}
}
public void onNothingSelected(AdapterView<?> parent)
{
}
Just compare with parent.getItemAtPosition(position) it will works..... Thank you.
于 2012-11-29T13:32:00.910 回答