I have a tabbed view in Android, and the tabs share the same xml layout, they are dynamically generated based on JSON. For example, if I have one Menu, it will create one tab. Two menus, two tabs. And so on. As all the tabs are based on the same "Menu" object, they share the same xml being inflated.
The construction of the tabs goes without problems. When have one or two tabs, changing states and swiping is done flawlessly. When having three or more tabs, swiping to right is working, but whenever I swipe back to left, I get this error:
java.lang.IllegalArgumentException: Wrong state class, expecting View State but received class android.widget.AbsListView$SavedState instead. This usually happens when two views of different type have the same id in the same hierarchy. This view's id is id/header_list_view. Make sure other views do not use the same id.
Here is my onCreateView code:
public class MenuToListFragment extends Fragment {
HeaderListView headerListView;
// (most of the logic removed)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_menu, container, false);
headerListView = (HeaderListView) rootView.findViewById(R.id.header_list_view);
return rootView;
}
}
And here is my xml layout:
<LinearLayout
xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="<removed>.DisplayMenus">
<com.applidium.headerlistview.HeaderListView
android:id="@+id/header_list_view"
android:layout_height="wrap_content"
android:layout_width="wrap_content" />
</LinearLayout>
Thanks for your help!