你好朋友我有旋转器如下
当我点击任何项目点击事件时,应该像下面那样设置
这意味着当我选择当时的Afghnistan时,应将其设置为AF,其余的国家/地区值保持不变,因为我的代码如下所示
点击Spinner项目
mSpinnerCountry.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
mStringCountryID=mArrayListCountryDatas.get(position).getId();
mSpinnerCountry.setPrompt(mArrayListCountryDatas.get(position).getIso_alpha()+"
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
});
当我在代码上方运行时,它没有设置值,我知道如何才能实现它?
答案 0 :(得分:1)
mSpinnerCountry.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
int mStringCountryID = s1.getSelectedItemPosition(); Toast.makeText(getBaseContext(),
"You have selected item : " + presidents[mStringCountryID],
Toast.LENGTH_SHORT).show();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
试试这个...变量mStringCountryID将保存您特定的完整值,执行您想要对此值执行的操作。