在获取祝酒消息时遇到一些问题,微调框选择的文本也没有设置为微调框。以下是无效的代码。
category_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
showMessage("Selected "+position+"");
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
public void showMessage(String message)
{
Toast.makeText(Activity.this,message,Toast.LENGTH_SHORT).show();
}
答案 0 :(得分:0)
尝试将getApplicationContext()
替换为Activity.this
,如下所示:
Toast.makeText(Activity.this,Toast.LENGTH_SHORT).show();