Не биндится метод
Подскажите, пожалуйста, почему в TextView не биндится метод? Выводится пустое значение текста в виджете.
fragment_beat_box.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="viewModel"
type="com.bignerdranch.android.beatbox.SoundViewModel"/>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2" />
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="20"
android:paddingLeft="8dp"
android:paddingTop="8dp"
android:paddingRight="8dp"
android:text="@{viewModel.textViewText}"
android:textAlignment="center" />
<SeekBar
android:id="@+id/seek_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="20"
android:padding="8dp" />
</LinearLayout>
</layout>
SoundViewModel.java
package com.bignerdranch.android.beatbox;
import android.widget.TextView;
import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;
public class SoundViewModel extends BaseObservable {
private Sound mSound;
private BeatBox mBeatBox;
//private String mTextViewText;
public SoundViewModel(BeatBox beatBox) {
mBeatBox = beatBox;
}
@Bindable
public String getTitle() {
return mSound.getName();
}
public Sound getSound() {
return mSound;
}
public void setSound(Sound sound) {
mSound = sound;
notifyChange();
}
@Bindable
public String getTextViewText() {
return "hello";
}
public void onButtonClicked() {
mBeatBox.play(mSound);
}
}
BeatBoxFragment.java
...
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
FragmentBeatBoxBinding binding = DataBindingUtil
.inflate(inflater, R.layout.fragment_beat_box, container, false);
binding.recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 3));
binding.recyclerView.setAdapter(new SoundAdapter(mBeatBox.getSounds()));
return binding.getRoot();
}
...