У меня есть текст для редактирования, который получит ввод от пользователя
<EditText
android:inputType="number"
android:id="@+id/etQuantity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/button_background"
android:backgroundTint="@color/green"
android:hint="Quantity"
android:padding="5dp"
android:onTextChanged="@{inspect::onQuantityTextChanged}"
android:textColor="@color/lightblack" />
<TextView
android:id="@+id/tvCalculatedTotal"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/button_background"
android:backgroundTint="@color/green"
android:hint="Total"
android:inputType="number"
android:padding="5dp"
android:text="@={inspect.calculatedTotal}"
android:textColor="@color/lightblack" />
Я хочу установить его для просмотра текста при обмене в тексте редактирования
class InspectViewModel(repository: UserRepository) : ViewModel() {
var calculatedTotal: String = ""
fun onQuantityTextChanged(
s: CharSequence,
start: Int,
before: Int,
count: Int
) {
calculatedTotal= s.toString()
}
}
Я получаю значение, но оно не обновляет текстовое представление, я использовал текущие данные, но получаю ANR