现在我要做的是,当我的CustomCheckboxSpec
组件在onCheckboxClicked
事件中发送参数的真或假值时isChecked
,它会调用CustomText
组件并通过setVisible
函数和参数,我可以定位哪些CustomText
元素我想在视觉上设置为真或错误的。
使用什么功能可以搜索其中的元素CustomText
?如何更改该元素的可见性?
//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
}*/
}