Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkboxes are purple #5

Open
ghost opened this issue Oct 2, 2017 · 4 comments
Open

Checkboxes are purple #5

ghost opened this issue Oct 2, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Oct 2, 2017

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!

@sevar83
Copy link
Owner

sevar83 commented Oct 2, 2017

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

@ghost
Copy link
Author

ghost commented Oct 2, 2017

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)

@sevar83
Copy link
Owner

sevar83 commented Oct 2, 2017 via email

@ghost
Copy link
Author

ghost commented Oct 2, 2017

I currently only use API 25+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant