3

次のコードを使用しています

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
4

1 に答える 1