Android 列表视图问题
我正在尝试从数据库中获取行,并从中创建列表视图 这是通过DbAdapter中的查询方法实现的Android 列表视图问题,android,listview,listviewitem,Android,Listview,Listviewitem,我正在尝试从数据库中获取行,并从中创建列表视图 这是通过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 + "="
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);
}
这就是我要写的代码。但这是一个错误
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
这是一个简单的编译错误。 请查看以下公共施工人员: SimpleCursorAdapter(上下文上下文、int布局、光标c、字符串[]从、int[]到)
您提供的是DBAdapter,应该在其中提供游标。很可能您应该传递inbox变量而不是DBAdapter这是一个简单的编译错误。 请查看以下公共施工人员: SimpleCursorAdapter(上下文上下文、int布局、光标c、字符串[]从、int[]到)
您提供的是DBAdapter,应该在其中提供游标。您很可能应该传递inbox变量,而不是DBAdapter构造函数SimpleCorsorAdapter(InboxActivity,int,DBAdapter,String[],null)未定义构造函数SimpleCorsorAdapter(InboxActivity,int,DBAdapter,String[],null)未定义