如何用字符串定义游标值?
我有这个字符串 “android.database.sqlite.SQLiteCursor@44defce0” 我如何用该字符串创建光标值?
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
input = auto.getText().toString();//this class use implements TextWatcher
KamusDbAdapter x = new KamusDbAdapter(getApplicationContext());
x.open();
Cursor cur = x.getCall(input, selection);
x.close();//getCall() to get cursor from sqlite result
String[] displayFields = new String[] {"word", "meaning"};
//word & meaning are fields inside the table
int[] displayViews = new int[] { android.R.id.text1,android.R.id.text2 };
auto.setAdapter(new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cur,displayFields, displayViews));
}
onitem 单击调用
auto.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
main = auto.getText().toString();
result.setText(main);
auto.setText("");
}
});
i have this string
"android.database.sqlite.SQLiteCursor@44defce0"
how can i make a cursor value with that string?
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
input = auto.getText().toString();//this class use implements TextWatcher
KamusDbAdapter x = new KamusDbAdapter(getApplicationContext());
x.open();
Cursor cur = x.getCall(input, selection);
x.close();//getCall() to get cursor from sqlite result
String[] displayFields = new String[] {"word", "meaning"};
//word & meaning are fields inside the table
int[] displayViews = new int[] { android.R.id.text1,android.R.id.text2 };
auto.setAdapter(new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cur,displayFields, displayViews));
}
onitem click invoke
auto.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
main = auto.getText().toString();
result.setText(main);
auto.setText("");
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不太确定您的代码与您的问题有什么关系,但您可以使用 MatrixCursor 在代码中创建光标。例如:
这将为您提供一个游标对象,其中包含名为“column1”的单列,以及包含您提到的字符串的单行。如果您愿意,可以将该游标传递给需要游标的适配器。
Not quite sure what your code has to do with your question, but you can use
MatrixCursor
to create cursors in code. For example:This will give you a cursor object with a single column named "column1", with a single row containing the string you mention. This cursor can then be passed to an adapter expecting a cursor, if you wish.