2012-03-02 7 views
-1

私はローカルのモバイルSQLiteデータベースからデータを取得し、Custome Simple Cursorアダプタクラスに送信しようとするアプリケーションを実装しました。私はBroadCast Recieverからデータを受信して​​います。これはDBから最新のレコードを取得するために使用されます。SimpleCursorAdapter私はSqlite DBからデータを取得し、UI.Butに更新することができます私はどのようにCustomeSimpleCursorAdapterにDBのコンテンツを渡すことができますCustomeSimpleCursorAdapter.SoにDBのコンテンツを渡すことはできません? I代わりSimpleCursorAdapterのCustomeSimpleCursorAdapterを使用する場合、どのように MySqliteHelper.USER_NAMEMySqliteHelper.USER_MESSAGEにまでコンテンツを表示することができるCustome Simple CursorアダプタのSQLiteからデータを取得してリストに表示する方法はありますか?

同様

 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(); 

     } 
    }; 

、次のようにIコードを実装している

リスト? 体を助けてください。

+0

-1我々は唯一の私の最初の推測がある...それを行う方法を推測することができます..あなたはCustomeSimpleCursorAdapter ... – Selvin

+0

のための適切なコンストラクタを提供しなかったCustomeSimpleCursorAdapter定義せずにちょっと適切answer.y与えられたいくつかのいずれかを参照してくださいあなたは諦めましたか? –

答えて

1

CursorAdapterのカスタムアダプターサブクラスを作成する場合は、bindViewおよびnewViewメソッドをオーバーライドする必要があります。

public class CustomCursorAdapter extends CursorAdapter { 
    public CustomCursorAdapter(Context context, Cursor c) { 
     super(context, c); 
    } 

    @Override 
    public void bindView(View view, Context context, Cursor cursor) { 
     TextView username = (TextView)view.findViewById(R.id.username); 
     username.setText(cursor.getString(
       cursor.getColumnIndex(MySqliteHelper.USER_NAME))); 
     // Set up other view here 
     // ... 
    } 

    @Override 
    public View newView(Context context, Cursor cursor, ViewGroup parent) { 
     LayoutInflater inflater = LayoutInflater.from(context); 
     View v = inflater.inflate(R.layout.listItem, parent, false); 
     bindView(v, context, cursor); 
     return v; 
    } 
} 
+0

LazyLoad画像読み込みのような画像を取得できますか? –

関連する問題