【发布时间】:2021-09-23 14:28:29
【问题描述】:
我正在尝试将数据从我的班级获取到我的 xml 文件,因此我尝试使用数据绑定。但是数据绑定库不起作用。当我在我的 xml 文件中写入 '''plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id("androidx.navigation.safeargs")
id 'com.google.gms.google-services'
id "org.jetbrains.kotlin.kapt"
id 'kotlin-kapt'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.cagataysencan.forumfisk_it"
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
buildFeatures {
dataBinding true
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//Navigation v Google Maps
implementation("androidx.navigation:navigation-fragment-ktx:2.3.5")
implementation("androidx.navigation:navigation-ui-ktx:2.3.5")
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Firebase
implementation platform('com.google.firebase:firebase-bom:28.2.0')
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx'
implementation 'com.google.firebase:firebase-storage-ktx'
// Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
// ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1")
implementation("androidx.lifecycle:lifecycle-service:2.3.1")
implementation("androidx.lifecycle:lifecycle-process:2.3.1")
implementation("androidx.lifecycle:lifecycle-reactivestreams-ktx:2.3.1")
testImplementation("androidx.arch.core:core-testing:2.1.0")
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
implementation 'com.squareup.retrofit2:converter-gson:2.8.1'
implementation "com.squareup.retrofit2:adapter-rxjava2:2.8.1"
// RX Java
implementation "io.reactivex.rxjava2:rxjava:2.2.9"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
// Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
// Room
implementation 'androidx.room:room-rxjava2:2.3.0'
implementation "androidx.room:room-guava:2.3.0"
implementation "androidx.room:room-ktx:2.3.0"
implementation ("androidx.room:room-runtime:2.3.0")
annotationProcessor "androidx.room:room-compiler:2.3.0"
kapt("androidx.room:room-compiler:2.3.0")
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1"
}**
【问题讨论】:
-
"当我在我的 xml 文件中写入
-
没有。我无法在 xml 文件中打开像 这样的标签。这给我一个错误:“这里不允许元素数据。”
-
你能显示任何代码来表明你是如何尝试生成 xml 的吗?
标签: java android kotlin data-binding