我已經實現了一個應用程序來從本地移動SQLite數據庫獲取數據,並嘗試發送到Custome簡單光標適配器類。我從BroadCast Reciever接收數據它用於從DB獲取最新記錄。如果使用SimpleCursorAdapter,那麼我可以從Sqlite數據庫獲取數據並更新爲UI.But但無法將數據庫內容傳遞給CustomeSimpleCursorAdapter.So如何將db內容傳遞給CustomeSimpleCursorAdapter?如何從SQLite中將數據從Custome Simple Cursor適配器中獲取並顯示在列表中?
我已經實現的代碼如下:
private BroadcastReceiver myReceiver = new BroadcastReceiver()
{
@Override
public void onReceive(Context context, Intent intent) {
msh = new MySqliteHelper(GetMsgsScreen.this);
msh.openToWrite();
lst = ((ListView)findViewById(R.id.listView1));
cursor = msh.queueAll();
getFromDB = new String[]{MySqliteHelper.USER_NAME,MySqliteHelper.USER_MESSAGE};
toView = new int[]{R.id.usrName,R.id.msgText};
cursor.moveToFirst();
lst.setAdapter(new SimpleCursorAdapter(GetMsgsScreen.this, R.layout.test, cursor, getFromDB, toView));
updateList();
}
};
同樣,
如果我使用CustomeSimpleCursorAdapter代替SimpleCursorAdapter然後我怎樣才能顯示 MySqliteHelper.USER_NAME和MySqliteHelper.USER_MESSAGE內容清單? 請任何機構幫助我。
-1不CustomeSimpleCursorAdapter定義,我們只能猜測該怎麼辦呢?我的第一個猜測是..你沒有爲CustomeSimpleCursorAdapter ... – Selvin 2012-03-02 10:00:11
提供適當的構造嘿看,有人給予適當answer.y你放棄了嗎? – 2012-03-02 10:08:57