我正在使用以下代码。
但是我在第一行收到了一个类转换异常。
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