2010-12-27 12 views
0

データベースから行をフェッチして、そこからリストビューを作成しようとしています。リストビューの問題

これは、これは私が記述しようとしていますコードですDbAdapter

public Cursor readInbox(long toId) throws SQLException { 
    return db.query(TABLE_MAILS, new String[] { ID, KEY_FROM, KEY_TO, 
      KEY_SUB, KEY_BODY, KEY_DATETIME, KEY_READ }, KEY_TO + "=" 
      + toId, null, null, null, null, null); 
} 

内のQueryメソッドです。しかし、その与えるエラー

public class InboxActivity extends ListActivity { 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.inbox); 

     DBAdapter db = new DBAdapter(InboxActivity.this); 
     db.open(); 
     long userID = Long.parseLong(MessagingApplication.getUserID()); 

     Cursor inbox = db.readInbox(userID); 
     startManagingCursor(inbox); 

     String[] Id = new String[] { DBAdapter.ID }; 

     SimpleCursorAdapter inboxmail = new SimpleCursorAdapter(this, R.layout.list_view, db, Id, null); 
     setListAdapter(inboxmail); 

     db.close(); 
    } 
} 

エラー:

The constructor SimpleCursorAdapter(InboxActivity, int, DBAdapter, String[], null) is undefined 
+0

どのようなエラーが発生しますか? –

+0

コンストラクタSimpleCursorAdapter(InboxActivity、int、DBAdapter、String []、null)は未定義です –

答えて

3

これは、単純なコンパイル・エラーがあります。 はhttp://developer.android.com/reference/android/widget/SimpleCursorAdapter.htmlでpublicコンストラクタを見ている:

SimpleCursorAdapter

(コンテキストコンテキスト、int型のレイアウト、カーソルCを、文字列[] INT []に、から)あなたは、あなたが提供しなければならないDBAdapterを提供していますカーソル。ほとんどの場合、DBAdapterの代わりに受信トレイ変数を渡す必要があります

関連する問題