Android Data Binding: visibility on include tag

前端 未结 9 739
旧时难觅i
旧时难觅i 2020-12-24 10:38

As per http://developer.android.com/tools/data-binding/guide.html#imports, we can have such simple expressions in visibility:



        
9条回答
  •  感情败类
    2020-12-24 11:37

    This is the direct approach, without having to pass the variable inside the included layout

    
    
        
    
    
    

    The above code was all I needed

    The interesting thing is if I remove the above ternary operator and simplify it like this,

    
    

    with addition of an BindingAdapter class with following method,

    @BindingAdapter("android:visibility")
        public static void setVisibility(View view, boolean isVisible) {
            view.setVisibility(isVisible ? View.VISIBLE : View.GONE);
        } 
    

    Boom! the OP error invades my entire BuildOutput trace, interesting world of Android

提交回复
热议问题