Android spinner/sqlite 数据库 - 获取光标位置而不是内容!
所以我的设置是我有一个包含两个表的数据库。我的主要输入类是一个基本表单,它有一个旋转器来选择类别。类别是第二个表,微调器由该数据库表驱动,主表具有该表的外键。
我已经正确填充了微调器等,但是当从微调器存储所选项目时,它存储的是光标位置,如下所示:
android.database.sqlite.SQLiteCursor@435b9ba0.
而不是它的实际内容,它应该是数据库中的名称。我使用的代码是:
String fkstring = mSpinner.getSelectedItem().toString();
如果有人能让我知道如何解决这个问题,那就太好了。
So my setup is that I have a database with two tables. My main input class is a basic form which has a spinner to select a category. Category is the second table, the spinner is powered by this database table and the main table has a foreign key of this table.
I have the spinner populating correctly etc but when storing the selected item from the spinner it is storing the cursor position which looks like:
android.database.sqlite.SQLiteCursor@435b9ba0.
rather than the actual contents of it which should be the name from the database. The code I am using is:
String fkstring = mSpinner.getSelectedItem().toString();
If anyone could let me know how to solve this that would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
.getString(0)
获取字符串,.getString(0)
将获取第一列.getString(1)
第二列等等等String fkstring = mSpinner.getSelectedItem().getString(0);
use
.getString(0)
to get a string,.getString(0)
will get the first column.getString(1)
the second etc etc.String fkstring = mSpinner.getSelectedItem().getString(0);
尝试 String fkstring = (String) mSpinner.getSelectedItem();
Try
String fkstring = (String) mSpinner.getSelectedItem();