【发布时间】:2019-02-15 06:33:50
【问题描述】:
我正在尝试设置我的 SettingsFragment,但是
import PreferenceFragmentCompat 一直没有工作。
有没有办法用 AndroidX 做到这一点?
依赖关系
implementation 'androidx.preference:preference:1.0.0-rc02'
摇篮飞翔
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.idealorb.payrollapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
android.defaultConfig.vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0-rc02'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-rc02'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-rc01'
implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha05'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha05'
implementation 'androidx.preference:preference:1.0.0-rc02'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
【问题讨论】:
-
您的意思是写
Framgment?这是Fragment。 -
是的。我的错误,它不起作用
-
所以你的代码中有
PreferenceFragmentCompat,而不是PreferenceFramgmentCompat,对吧? -
是的。
import androidx.preference.PreferenceFragmentCompat; -
成功了!在多次尝试同步 Gradle 代码之后。
标签: android android-studio androidx