Question

this is not working i would like to append the second SimpleAdapter over the 1st SimpleAdapter. but , it is getting overwritted and only the second list is being displayed.

I want to display both in a single list with different list format for each objects as list_item and list_item_new need help

    ListAdapter newAdapter = new SimpleAdapter(
                        NotificationTask.this, notificationsList,
                        R.layout.list_item_new, new String[] { TAG_PID,
                                TAG_NAME, TAG_DESCRIPTION},
                        new int[] { R.id.pid, R.id.name, R.id.description });

                newAdapter = new SimpleAdapter(
                          NotificationTask.this, oldNotificationsList,
                          R.layout.list_item, new String[] { TAG_NID,
                          TAG_NAME, TAG_DESCRIPTION},
                          new int[] { R.id.pid, R.id.name, R.id.description });

                //list.setAdapter(adapter);
                setListAdapter(newAdapter);

                        ((BaseAdapter) newAdapter).notifyDataSetChanged();
Was it helpful?

Solution

This is not possible, try to create a custom adapter able to handle both elements on the method getView (if one kind of view differs from the other).

The adapter is a middle man between the listview and its content, so each listview is able to manage just one adapter, this is the reason why it gets overwriten by the data located on the second adapter.

OTHER TIPS

I use MatrixCursor with SimpleCursorAdapter to combine multiple source of data to display.

You can override SimpleCursorAdapter.ViewBinder's setViewValue(View view, Cursor cursor, int columnIndex) method and specify the logic.

SimpleCursorAdapter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top