我在android MVVM体系结构中经常遇到此错误。我尝试删除.idea,igradle,gradle文件夹,但是它不起作用。我什至尝试使用无效缓存重新启动Studio,这也行不通。请帮助。
>下面是示例代码
public class TestViewModel extends AndroidViewModel {
MutableLiveData<String> test = new MutableLiveData<>();
public TestViewModel(@NonNull Application application) {
super(application);
}
public MutableLiveData<String> getTest() {
return test;
}
public void setTest(MutableLiveData<String> test) {
this.test = test;
}
}
和
<?xml version="1.0" encoding="utf-8"?>
<layout 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">
<data>
<import type="in.raji.bills.billsreminder.viewmodels.TestViewModel"
/>
<variable
name="viewModel"
type="in.raji.bills.billsreminder.viewmodels.TestViewModel"/>
</data>
<android.support.constraint.ConstraintLayout
android:id="@+id/relativeLayout8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
tools:context=".MonthlyFragment">
<EditText
android:id="@+id/autoCompleteTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:hint="Enter title"
android:text="@{viewModel.test}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
</layout>
答案 0 :(得分:0)
LiveData可用作Android Studio 3.1中的可观察字段。这是旧版Android Studio的错误,请更新您的Android Studio。 Check Release Notes。
建议
<?php
$title = (is_int($_POST['title']) && $_POST['title'] >= 1) ? $_POST['title'] : 0;
// This allows you to check whether $_POST['title'] is an integer, if it is 1 or higher. If that is the case, $title will be $_POST['title'], else it will become 0 (zero).
// It will also do a check on given $_POST data to prevent false input.
if ($title == 3): ?>
<input type="file" name="file" accept="image/gif,image/jpeg,image/png,image/jpg" />
<?php else: ?>
<input type="file" name="file" accept="application/pdf" />
<?php endif; ?>
<import type="in.raji.bills.billsreminder.viewmodels.TestViewModel"/>
设为私有。