int txt= (int) parent.getItemIdAtPosition(position)
当我在 Toast 中显示txt
变量时,我的应用程序会崩溃,我需要获取所选项目的 id,然后将该 id 保存在其他表中,请帮助我
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String id = spinner.getItemAtPosition(position).toString();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.