androidx

How to get an Instance of ViewModel in activity in 2020?

徘徊边缘 提交于 2020-05-27 09:25:26
问题 I am new to the mvvm pattern. I created a ViewModel for the main activity. Now I want to get an instance of the ViewModel in the main activity. Most Tutorials and answers here on Stackoverflow suggest using ViewModelProviders.of(... , but this is depreceated. So according to this question on stackoverflow: ViewModelProviders is deprecated in 1.1.0 main activity in onCreate, I do the following (and I could swear I already had it running): mainActivityViewModel = new ViewModelProvider(this).get

AndroidX SwipeRefreshLayout with DataBinding

久未见 提交于 2020-05-27 06:28:48
问题 I'm trying to implement swipe to refresh functionality using AndroidX library: androidx.swiperefreshlayout.widget.SwipeRefreshLayout My app is using Android Databinding therefore I'd like to use observable fields to control the state of this widget. In the past I've used AppCompat one - it has as since been deprecated. Before, I could access the fields in the following way: <android.support.v4.widget.SwipeRefreshLayout xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width=

Could not set unknown property 'useAndroidX' for object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension

自作多情 提交于 2020-05-25 10:41:25
问题 I want to add a library that i've found on github but it required androidx.I found out that i should put these: android.useAndroidX=true android.enableJetifier=true here defaultConfig { applicationId "com.kolydas.greeksinbrno" minSdkVersion 19 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" android.useAndroidX=true android.enableJetifier=true } But i got this error Could not set unknown property 'useAndroidX' for

Could not set unknown property 'useAndroidX' for object of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension

喜欢而已 提交于 2020-05-25 10:40:50
问题 I want to add a library that i've found on github but it required androidx.I found out that i should put these: android.useAndroidX=true android.enableJetifier=true here defaultConfig { applicationId "com.kolydas.greeksinbrno" minSdkVersion 19 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" android.useAndroidX=true android.enableJetifier=true } But i got this error Could not set unknown property 'useAndroidX' for

material checkbox style after customize

落爺英雄遲暮 提交于 2020-05-23 21:05:25
问题 My customized checkbox ( MyCheckbox ) has extended from androidx.appcompat.widget.AppCompatCheckBox , but the default styles don't apply to it. <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar"> ... <item name="android:checkboxStyle">@style/CheckboxTheme</item> <item name="checkboxStyle">@style/CheckboxTheme</item> </style> <style name="CheckboxTheme" parent="@style/Widget.AppCompat.CompoundButton.CheckBox"> <!-- for example try to change background --> <item name=

material checkbox style after customize

人走茶凉 提交于 2020-05-23 21:05:05
问题 My customized checkbox ( MyCheckbox ) has extended from androidx.appcompat.widget.AppCompatCheckBox , but the default styles don't apply to it. <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar"> ... <item name="android:checkboxStyle">@style/CheckboxTheme</item> <item name="checkboxStyle">@style/CheckboxTheme</item> </style> <style name="CheckboxTheme" parent="@style/Widget.AppCompat.CompoundButton.CheckBox"> <!-- for example try to change background --> <item name=

Is there any proguard rules should use while using EncryptedSharedPreferences?

三世轮回 提交于 2020-05-16 22:02:16
问题 before using EncryptedSharedPreferences my app works fine in release mode with (minifyEnabled = true), After adding the security library to my application the app crash while opening and if i use (minifyEnabled = false) the app works fine, i think i missing something to add it in proguard-rules.pro but i have searched a lot did not found anything. 回答1: Looks like something wrong with Tink obfuscation. My current workaround is add this rule to proguard: -keep class com.google.crypto.tink.** {

Is there any proguard rules should use while using EncryptedSharedPreferences?

杀马特。学长 韩版系。学妹 提交于 2020-05-16 22:01:03
问题 before using EncryptedSharedPreferences my app works fine in release mode with (minifyEnabled = true), After adding the security library to my application the app crash while opening and if i use (minifyEnabled = false) the app works fine, i think i missing something to add it in proguard-rules.pro but i have searched a lot did not found anything. 回答1: Looks like something wrong with Tink obfuscation. My current workaround is add this rule to proguard: -keep class com.google.crypto.tink.** {

Crash when using bundled ttf font on Android 10 / Android Q

半腔热情 提交于 2020-05-15 04:32:26
问题 After I updated the target level for my Android app from 28 to 29 (Android 10) the app crashes on a Pixel 3 (with Android 10). Versions used Android Gradle Plugin 3.5.0 Gradle 5.5.1 Question: Is this a known issue? Details The crash happens on various layouts using different tags (TextView, androidx.appcompat.widget.AppCompatTextView, etc) I use the attribute "android:fontFamily" and reference a font bundled in one of my external libraries. The font file, opensans_regular.ttf , is placed in

ANDROID: Error inflating class android.support.design.widget.AppBarLayout

可紊 提交于 2020-05-14 21:32:08
问题 I added a toolbar to my layout and now I get this error when running: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/mainactivity.MainActivity}: android.view.InflateException: Binary XML file line #9: Binary XML file line #2: Error inflating class android.support.design.widget.AppBarLayout This is my activity layout: <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas