Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一种显示查询的方法:
public Cursor getQuery() { String Fav="SELECT score, difficulty, date FROM score LIMIT 15'"; Cursor c=db.rawQuery(Fav,null); return c; }
我将如何在我的 OnCreate() 的文本视图中使用它?
我假设,您想显示通过查询获得的结果数据。
现在,要将数据显示到 TextView 中,您必须编写代码来遍历 cursor。
例如:
String strData = ""; if (c!= null) { if (c.moveToFirst()) { do { strData += cursor.getString(Fieldindex)); } while (c.moveToNext()); } } textview.setText(strData);