我正在研究一个简单的微调器。我想在点击的任何项目上显示一个toast消息,但它不起作用。我不知道逻辑错误在哪里。任何帮助将不胜感激。 这是我的代码:
public void onItemSelected(AdapterView<?> adapter, View view, int position, long id) {
// On selecting a spinner item
String itemSelected = adapter.getItemAtPosition(position).toString();
int temp=Integer.parseInt(itemSelected);
switch (position) {
case 0:
Toast.makeText(getApplicationContext(), "Selected: user", Toast.LENGTH_LONG).show();
break;
case 1:
Toast.makeText(getApplicationContext(), "Selected: page", Toast.LENGTH_LONG).show();
break;
}
// Showing selected spinner item
//Toast.makeText(adapter.getContext(), "Selected: " + itemSelected, Toast.LENGTH_SHORT).show();
}