I have this Kotlin code:
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