我有这个 Kotlin 代码:
if(this.fragmentMeasurementBinding.viewStub.isInflated)
{
return;
}
this.fragmentMeasurementBinding.viewStub.viewStub?.layoutResource =
R.layout.layout_measurement_single_value
this.fragmentMeasurementBinding.viewStub.setOnInflateListener { _, inflated ->
LayoutMeasurementSingleValueBinding.bind(inflated)?.let {
it.textInputLayoutSingleMeasurementValue.hint = Helper.getDynamicStringResource(
this.context, parent.getItemAtPosition(position).toString(), prefix = "title_")
}
}
this.fragmentMeasurementBinding.viewStub.viewStub?.inflate()
这在我的 XML 文件中:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.MeasurementFragment">
<ViewStub
android:id="@+id/viewStub"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_input_layout_measure" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/text_input_layout_measure"
style="@style/AppTheme.Widget.TextInput.ExposedDropdownMenu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:descendantFocusability="blocksDescendants"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<AutoCompleteTextView
android:id="@+id/exposed_dropdown_measure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/what_are_you_measure"
android:imeOptions="actionNext"
android:labelFor="@id/text_input_layout_measure" />
</com.google.android.material.textfield.TextInputLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
当我编译 Android Studio 时报告以下错误:
- 未解决的参考:isInflated
- 未解决的参考:viewStub
- 未解决的参考:viewStub
我正在使用来自 Google 的新 ViewBinding 我正在使用 Android Studio 3.6 Canary 12、Gradle 3.6.0-alpha12 开发。这是 Android Studio 的错误还是我的错误?