Eclipse給我錯誤此行 ArrayAdapter myAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_2,myArray);Java文件錯誤(Android)
下面是代碼:
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);
}
}
這不是主要的活動,它只是另一項活動。
後logcat的...... – KOTIOS
你得到什麼錯誤? – Shiv