我的问题是sp1.getSelectedItem().toString();
只将数据保存为android.database.SQLite.cursor@blablabla
...它没有得到我声明的字符串......我怎么能这样做?
这是我的游标代码[填充微调器]
cursor = mySQLiteAdapter.queueSchoolAll();
cursor.requery();
String[] from1 = new String[]{Database.KSCHOOLCODE};
int[] to1 = new int[]{R.id.rt1};
cursorAdapter =
new SimpleCursorAdapter(this, R.layout.a_row_school, cursor, from1, to1);
sp1.setAdapter(cursorAdapter);
这是保存数据的按钮代码:
String data1 = (String)sp1.getSelectedItem().toString();
mySQLiteAdapter.insertGrade(data1);
答案 0 :(得分:1)
您需要从光标获取数据。 例如:
public xxxxxx onItemClickFunction(..., int position,....){
int pos = cursor.getPosition();//saving the position just in case
cursor.moveToPostion(position);// moving to the position where a click is fired
String val = cursor.getString(column index);
cursor.moveToPosition(pos);// moving back to original position.
}
答案 1 :(得分:1)
尝试
String data1 = ((Cursor) sp1.getSelectedItem()).getString(0);
mySQLiteAdapter.insertGrade(data1);