如何在CursorAdapter中使用2个游标?

发布于 2024-12-26 03:57:25 字数 877 浏览 1 评论 0原文

我想显示给定电话号码的收件箱和发送的消息。我的适配器是这样的:

public class MessageListAdapter extends CursorAdapter {

LayoutInflater inflater;

public MessageListAdapter(Context context, Cursor inbox) {

        super(context, inbox);
        inflater = LayoutInflater.from(context);
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {

        TextView messagetext= (TextView) view.findViewById(R.id.message);
        messagetext.setText(inbox.getString(0));

        TextView date= (TextView) view.findViewById(R.id.message);
        date.setText(inbox.getString(1));

    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup group) {
        View view = inflater.inflate(R.layout.inboxlistitems, null);
        return view;
    }

}

我希望它按日期排序,就像默认消息应用程序中的对话一样。我该怎么做呢?是否可能,或者我应该使用 ArrayAdapter?

I want to display inbox and sent messages for a given phone number. My adapter is like this :

public class MessageListAdapter extends CursorAdapter {

LayoutInflater inflater;

public MessageListAdapter(Context context, Cursor inbox) {

        super(context, inbox);
        inflater = LayoutInflater.from(context);
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {

        TextView messagetext= (TextView) view.findViewById(R.id.message);
        messagetext.setText(inbox.getString(0));

        TextView date= (TextView) view.findViewById(R.id.message);
        date.setText(inbox.getString(1));

    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup group) {
        View view = inflater.inflate(R.layout.inboxlistitems, null);
        return view;
    }

}

I want it to be sorted by date, like a conversation in default messaging app. How can I do it? is it possible, or should I use instead an ArrayAdapter?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文