2

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?

Samet
  • 917
  • 12
  • 26

1 Answers1

2

I think you could use a mergeCursor:

http://developer.android.com/reference/android/database/MergeCursor.html

You can find an example here:

ListView using two cursoradapters?

Community
  • 1
  • 1
Jeroen Coupé
  • 1,394
  • 11
  • 13