Eclipse 在这条线上给了我错误 ArrayAdapter myAdapter=new ArrayAdapter(this,android.R.layout.simple_list_item_2,myArray);
这是代码:
package com.dbapp.activities;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class SecondActivity extends Activity {
int i,j;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
String[][] myArray=new String[10][10];
ListView myListView=(ListView)findViewById(R.id.lv1);
CRUD crud=new CRUD(this);
crud.openDb();
Cursor cursor= crud.readDbRows();
cursor.moveToFirst();
i=j=0;
while (cursor.moveToNext())
{
myArray[i][0]=cursor.getString(cursor.getColumnIndex("column1"));
myArray[i][1]=cursor.getString(cursor.getColumnIndex("column2"));
}
ArrayAdapter<String> myAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_2,myArray);
myListView.setAdapter(myAdapter);
}
}
这不是主要活动,它只是另一个活动。