How To Properly "setMutableVisiblity"?
I'm trying to create a function, setMutableVisibility
. The thing is that I'm supposed to use another function but I got an error. I do not understand why. Furthermore one of my friend just did the same function on his computer but he didn't get the error...
@BindingAdapter("mutableVisibility")
fun setMutableVisibility(view: View, visibility: MutableLiveData<Int>?) {
val parentActivity: AppCompatActivity? = view.getParentActivity()
if(parentActivity != null && visibility != null) {
visibility.observe(parentActivity, Observer{ value -> view.visibility = value?:View.VISIBLE})
}
}
AS* is telling me that "parentActivity" is the wrong type, I think it's not the case. But here the advice from AS :
Type mismatch. Required: LifecycleOwner Found: AppCompatActivity?
Thank you for your answers.
*AS: Android Studio
Answer
This issue exist due to the fact that older support library does not integrate well with latest lifecycle components and there is some known issue / bug as mentioned by Ian in this post. You need to use latest version of AppCompat to fix this. Try:
implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
And make sure all other support libraries are also upgraded to compatible version (or same if it exists).
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View