How to set a component visible true or false when another component do a action

195 Views Asked by At

Now what I'm trying to do is that when my CustomCheckboxSpec component in the onCheckboxClicked event sends a true or false value for the isChecked parameter, it calls the CustomText component and through the setVisible function and by the parameters I can locate which CustomText elements I want to put visually true or false.

With what function I can search for the elements in CustomText? How can I change the visibility for that element?

//CustomCheckboxSpec class
@LayoutSpec
public class CustomCheckboxSpec {
 ...`enter code here`
     @OnEvent(ClickEvent.class)
    static void onCheckboxClicked(
            ComponentContext c, @FromEvent View view
            , @Prop OnCheckboxClickListener listener, @State boolean isChecked
            , @Prop int idPregunta, @Prop int idRespuesta) {
        listener.onCheckboxClick(!isChecked, idPregunta, idRespuesta);
        CustomCheckbox.updateCheckboxAsync(c);
    }
}
//MainActivity class
CustomCheckbox.create(componentContext).listener(new CustomCheckboxSpec.OnCheckboxClickListener() {
@Override
 public void onCheckboxClick(boolean valor, int idPregunta, int idRespuesta) 
{
   /*call the component CustomTextSpec and in function
    @OnUpdateState
    static void setVisible(someParams) {
        //with params search for child
        //change child visibility
    }*/                                               
}
0

There are 0 best solutions below