正如我在标题中所说,我想将光标的值保存到字符串数组中。我将在 ArrayAdapter 中使用这个数组并调用 setLineAdapter(ArrayAdapter).. 我有这些代码,但 LogCat 说在arr[i] = crr.getString(i)行有问题......有人可以帮我吗?
DBAdapter db;
String arr[];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
db = new DBAdapter(this);
db.open();
ArrayAdapter<String> AA = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, arr);
try {
Cursor crr = db.getRecord(4);
crr.moveToFirst();
for (int i = 0; i <= cr.getCount(); i++){
arr[i] = cr.getString(i);
crr.moveToNext();
}}
catch (IOException e) {e.printStackTrace();}
setListAdapter(AA);
db.close();