我试图用从其他函数获取的 ArrayListView
以一个 ArrayList
来弹出动态创建的
“The buildor ArrayAdapter< String> (showRecords, ListView, ArrayList < String>) 定义不清的“
。 以下是我为 Listactivity
的代码 :
public class ShowRecords extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
DatabaseHandler db = new DatabaseHandler(this);
ArrayList<String> records = db.getRecords();
ListView lv = new ListView(this);
this.setListAdapter(new ArrayAdapter<String>(this, lv, records));
}
}
s 这里我对 getRecords ()
函数的代码 :
public ArrayList<String> getRecords() {
ArrayList<String> recordList = new ArrayList<String>();
String selectQuery = "SELECT millis FROM records ORDER BY CAST(millis as SIGNED) DESC LIMIT 10";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
recordList.add(cursor.getString(0));
} while (cursor.moveToNext());
}
}
return recordList;
}
我该如何解决这个问题?