Android 如何将数据从SQLite中获取到Custome Simple Cursor adapter并显示在列表中?

Android 如何将数据从SQLite中获取到Custome Simple Cursor adapter并显示在列表中?,android,custom-action,simplecursoradapter,custom-cursor,Android,Custom Action,Simplecursoradapter,Custom Cursor,我已经实现了一个从本地移动SQLite db获取数据的应用程序,并尝试发送到Custome Simple Cursor adapter类。我正在从广播接收器接收数据,它用于从db获取最新记录。如果使用SimpleCursorAdapter,则我可以从SQLite db获取数据并更新到UI。但我无法将db内容传递给用户CustomeSimpleCursorAdapter。那么如何将db内容传递给CustomeSimpleCursorAdapter呢 我实现了如下代码: private B

我已经实现了一个从本地移动SQLite db获取数据的应用程序,并尝试发送到Custome Simple Cursor adapter类。我正在从广播接收器接收数据,它用于从db获取最新记录。如果使用SimpleCursorAdapter,则我可以从SQLite db获取数据并更新到UI。但我无法将db内容传递给用户CustomeSimpleCursorAdapter。那么如何将db内容传递给CustomeSimpleCursorAdapter呢

我实现了如下代码:

     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\u NAMEMySqliteHelper.USER\u MESSAGE要列出的内容?
请任何人帮助我。

如果要创建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;
    }
}

-1没有自定义SampleCursorAdapter定义,我们只能猜测如何操作。。。我的第一个猜测是。。你没有为CustomeSimpleCursorAdapter提供正确的构造函数…嘿,看到有人给出了正确的答案。你放弃了吗?我们能得到像LazyLoad这样的图像加载吗?