我正在使用以下代码
ConsumersFiltersAdapter genderFilterAdapter, ageFilterAdapter,
lastCheckinFilterAdapter, customerTypeAdapter;
genderFilterListView.setAdapter(genderFilterAdapter);
ageFilterListView.setAdapter(ageFilterAdapter);
lastCheckinFilterListView.setAdapter(lastCheckinFilterAdapter);
customerFilterListView.setAdapter(customerTypeAdapter);
genderFilterListView.setOnItemClickListener(this);
ageFilterListView.setOnItemClickListener(this);
lastCheckinFilterListView.setOnItemClickListener(this);
customerFilterListView.setOnItemClickListener(this);
然后我实现以下功能
@Override
public void onItemClick(final AdapterView<?> listView, final View view,final int position, final long id) {
ConsumersFiltersAdapter consumersFiltersAdapter=(ConsumersFiltersAdapter)listView.getAdapter();
consumersFiltersAdapter.setSelectedIndex(position);
}
但我在第一行得到一个类转换异常
java.lang.ClassCastException: android.widget.HeaderViewListAdapter cannot be cast to com.abc.merchant.adapter.ConsumersFiltersAdapter