how to define a cursor value with string?
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("");
}
});
Not quite sure what your code has to do with your question, but you can use MatrixCursor
to create cursors in code. For example:
MatrixCursor cursor = new MatrixCursor(new String[] {"column1"});
cursor.addRow(new String[] {"android.database.sqlite.SQLiteCursor@44defce0"});
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.
精彩评论