indeterminate-checkbox icon indicating copy to clipboard operation
indeterminate-checkbox copied to clipboard

Checkboxes are purple

Open ghost opened this issue 8 years ago • 4 comments

Hello,

For some reason when attempting to dynamically generate these, the checkbox appears on the UI as a purple colour that does not exist in my styles nor colour file. Any idea what's going on? capture Thanks!

ghost avatar Oct 02 '17 14:10 ghost

Is the screenshot from the app or from the layout editor? Please, post some source code and xmls.

sevar83 avatar Oct 02 '17 15:10 sevar83

The screenshot is from the app itself, here is the source code that generates the checkboxes:

for(int i = 0; i <= 11; i++) { // loop as many times as needed for parent; i<=category.length
            dynamicParentCheckBox = new IndeterminateCheckBox(mActivity.getApplicationContext());
            // if has child, create dynamicChildCheckbox
            dynamicParentCheckBox.setTextColor(mActivity.getResources().getColor(R.color.white));
            dynamicParentCheckBox.setText("Parent Category " + i ); // TODO: switch to getCategoryName
            dynamicParentCheckBox.setOnStateChangedListener(new IndeterminateCheckBox.OnStateChangedListener() {
                @Override
                public void onStateChanged(IndeterminateCheckBox indeterminateCheckBox, @Nullable Boolean state) {
                    if(state = null) {
                        //indeterminate
                    } else if(state) {
                        //checked
                    } else {
                        //unchecked
                    }
                }
            });
            mDialogContainer.addView(dynamicParentCheckBox);
            if(hasChild) {
                for(int j = 0; j <= 3; j++) { //loop as many times as needed for children; i <= subcategory.length
                    dynamicChildCheckBox = new IndeterminateCheckBox(mActivity.getApplicationContext());
                    dynamicChildCheckBox.setTextColor(mActivity.getResources().getColor(R.color.white));
                    dynamicChildCheckBox.setText("Child Category " + j); // TODO: switch to getSubcategoryName
                    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                    params.setMargins(60, 0, 0, 0);
                    dynamicChildCheckBox.setLayoutParams(params);

                    dynamicChildCheckBox.setOnStateChangedListener(new IndeterminateCheckBox.OnStateChangedListener() {
                        @Override
                        public void onStateChanged(IndeterminateCheckBox indeterminateCheckBox, @Nullable Boolean state) {
                            if(state = null) {
                                //indeterminate
                                // this wont happen since subcategories have no children
                            }
                            else if(state) {
                                //checked
                            }
                            else {
                                //unchecked
                            }
                        }
                    });


                    mDialogContainer.addView(dynamicChildCheckBox);

                }
            }


        }

The only XML is a LinearLayout inside of a ScrollView that the elements are added to (mDialogContainer)

ghost avatar Oct 02 '17 15:10 ghost

Please try which API levels fail exactly.

On Mon, 2 Oct 2017 at 18:09 Tim [email protected] wrote:

The screenshot is from the app itself, here is the source code that generates the checkboxes:

for(int i = 0; i <= 11; i++) { // loop as many times as needed for parent; i<=category.length dynamicParentCheckBox = new IndeterminateCheckBox(mActivity.getApplicationContext()); // if has child, create dynamicChildCheckbox dynamicParentCheckBox.setTextColor(mActivity.getResources().getColor(R.color.white)); dynamicParentCheckBox.setText("Parent Category " + i ); // TODO: switch to getCategoryName dynamicParentCheckBox.setOnStateChangedListener(new IndeterminateCheckBox.OnStateChangedListener() { @Override public void onStateChanged(IndeterminateCheckBox indeterminateCheckBox, @Nullable Boolean state) { if(state = null) { //indeterminate } else if(state) { //checked } else { //unchecked } } }); mDialogContainer.addView(dynamicParentCheckBox); if(hasChild) { for(int j = 0; j <= 3; j++) { //loop as many times as needed for children; i <= subcategory.length dynamicChildCheckBox = new IndeterminateCheckBox(mActivity.getApplicationContext()); dynamicChildCheckBox.setTextColor(mActivity.getResources().getColor(R.color.white)); dynamicChildCheckBox.setText("Child Category " + j); // TODO: switch to getSubcategoryName RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.setMargins(60, 0, 0, 0); dynamicChildCheckBox.setLayoutParams(params);

                dynamicChildCheckBox.setOnStateChangedListener(new IndeterminateCheckBox.OnStateChangedListener() {
                    @Override
                    public void onStateChanged(IndeterminateCheckBox indeterminateCheckBox, @Nullable Boolean state) {
                        if(state = null) {
                            //indeterminate
                            // this wont happen since categories have no children
                        }
                        else if(state) {
                            //checked
                        }
                        else {
                            //unchecked
                        }
                    }
                });


                mDialogContainer.addView(dynamicChildCheckBox);

            }
        }


    }

The only XML is a LinearLayout inside of a ScrollView that the elements are added to (mDialogContainer)

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/sevar83/indeterminate-checkbox/issues/5#issuecomment-333563788, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHS1Yet2ZmMQX8vvmZmlbV7EjNrZIDaks5soPyxgaJpZM4PqsTr .

sevar83 avatar Oct 02 '17 15:10 sevar83

I currently only use API 25+

ghost avatar Oct 02 '17 15:10 ghost