vendredi 3 juin 2016

Get all items from adapter (recyclerview) in Fragment

Hello I'm having an issue getting all of the items from my adapter in my fragment. To be more specific I am using a ScaleInAnimatorAdapter along with my Customer Adapter and when I attempt to get my checkbox items from the below posted code, within my Fragment, I only seem to get the visible items on screen.

private View.OnClickListener onAllClick = new View.OnClickListener() {
    @Override public void onClick(View v) {
        int count = listAdapter.getItemCount();

        for (int i = 0; i < count; i++) {
            View mChild = listTopics.getChildAt(i);

            if( mChild != null ) {
                Log.d(TAG,"getItemCount(): " + i );

                CheckBox cBox = (CheckBox)mChild.findViewById(R.id.topic_chk);
                cBox.setChecked(((CheckBox) v).isChecked());
                Log.d(TAG,"isChecked" + cBox.getTag());
                cBox.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if(((CheckBox) v).isChecked()) {
                            checkboxAll.setChecked(false);
                        }
                    }
                });
            }
        }
    }
};

Essentially I am attempting to create a check all feature from the fragment, so that when this is clicked all of the checkbox items from the adapter are checked. I got that to work with the code I presented however the main issue is that I only get the items visible on the screen, so when I scroll to my other items they are not checked. Thus I am wondering if there is a better way or another way for me to get all of the items




Aucun commentaire:

Enregistrer un commentaire