문제

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();
도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top