It's okay when it runs in android with API 28. But when switching to API 23 it shows ClassCastException.
Here's my code
Here's the Java code snippet
private void setUpListView(){
ExpandableListView expandableListView = view.findViewById(R.id.fragment_transaction_viewpager_expandablelistview);
expandableListView.setVisibility(View.GONE);
listView = view.findViewById(R.id.fragment_transaction_viewpager_listview);
// per item kalau diclick
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
viewWallet(id);
}
});
listView.addHeaderView(header, null, false);
setUpAdapter();
}
private void setUpAdapter(){
adapter = new WalletAdapter(fragment.getActivity(), null);
listView.setAdapter(adapter);
}
The WalletAdapter extends CursorAdapter
Here's the error log
java.lang.ClassCastException: androidx.viewpager.widget.ViewPager$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
at android.widget.ListView.clearRecycledState(ListView.java:543)
at android.widget.ListView.resetList(ListView.java:529)
at android.widget.ListView.setAdapter(ListView.java:473)
at com.example.duitku.wallet.fragment.WalletFragmentView.setUpAdapter(WalletFragmentView.java:124)
at com.example.duitku.wallet.fragment.WalletFragmentView.setUpListView(WalletFragmentView.java:113)
at com.example.duitku.wallet.fragment.WalletFragmentView.setUpUI(WalletFragmentView.java:50)
at com.example.duitku.wallet.fragment.WalletFragment.onCreateView(WalletFragment.java:30)
Thank you in advance! I appreciate every answer
question from:
https://stackoverflow.com/questions/65886367/classcastexception-androidx-viewpager-widget-viewpagerlayoutparams-cannot-be-c 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…