我已经创建了一个微调器,并且微调器的项目来自数据库。然而,当我使用如何让android上的微调字符串值?
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
typeOFBCard = contactSpinner.getSelectedItem().toString();
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}
当我把这个监听器,并尽量挑选微调所选择的字符串,我得到的sglite像一个参考:
[email protected]
这是返回值typeOfBCard。
但是,在微调器上,我可以看到正常的字符串,如“工作”。
这里是我的初始化微调:
contactSpinner = (Spinner) findViewById(R.id.contactSpinner);
mobileText =(EditText) findViewById(R.id.mobileText);
mDbHelper = new DbAdapter(this);
mDbHelper.open();
cursor = mDbHelper.fetchAllBusinessCards();
startManagingCursor(cursor);
context =this;
contactSpinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
PLease添加如何初始化微调框。 – Ivan
你的问题是什么?你没有得到字符串?你是否遇到异常? – AedonEtLIRA
可能是[这个问题]的副本(http://stackoverflow.com/questions/5818850/android-spinner-selected-item) – theisenp