我正在尝试使用从另一个函数获取的动态创建ListView
的填充。ArrayList
我得到了错误"The constructor ArrayAdapter<String>(ShowRecords, ListView, ArrayList<String>) is undefined"
。这是我的代码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));
}
}
这是我的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;
}
我该如何解决?