1

I am using table layout.I alternate the bg color of table rows (grey & white strip) but when i use search (code below), i have to restyle the table. In the code below, i am able to style only the single column. How can i style all five column. I tried few things but all in vain? Any help is appreciated. Thankyou.

    searchTextField.addDataChangeListener(new DataChangedListener() {
        @Override
        public void dataChanged(int type, int index) {
            String getTextField = searchTextField.getText().toLowerCase();
            int counter = 0;
            int counterVisible = 0;
            boolean show = false;
            TextArea ta = new TextArea();
            for (Component c : containerTableData) {
                c.setName("searchContainer");
                Container cnt;
                cnt = (Container) c;

                if (counter % 5 == 0) {
                    ta = (TextArea) cnt.getComponentAt(0);
                    ta.setName("" + counter);
                    show = ta.getText().toLowerCase().indexOf(getTextField) > -1;
                }
                cnt.setHidden(!show);
                cnt.setVisible(show);

                if (cnt.isVisible()) {
                    cnt.setUIID("isVisible");
                    if (counterVisible % 2 == 0) {
                        ta.getParent().getAllStyles().setBgTransparency(255);
                        ta.getParent().getAllStyles().setBgColor(0xcccccc);
                    } else {
                        ta.getParent().getAllStyles().setBgTransparency(255);
                        ta.getParent().getAllStyles().setBgColor(0xffffff);
                    }
                    counterVisible++;
                }
                counter++;
            }
            containerTableData.animateLayout(200);
        }
    });

What i get now is this. I need entire row of same bg color

enter image description here

1 Answer 1

0

When setting the background you are calling ta.getParent().getAllStyles() instead of cnt.getAllStyles().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.