我有一个文本视图,需要为其创建一个onLongClick的监听器。目前针对相应的ViewModel,它具有一个名为sendLogs()的函数,该函数处理onClick的逻辑。如果我将onClick更改为onLongClick,该函数将不会被调用。 是否有任何方法使其在onLongClick下工作?
onClick直接与我的模型类函数相关联,但不是onLongClick。因此,我认为模型类绑定是正确的,但我可能需要一些额外的工作。
<data>
<import type="android.view.View" />
<variable
type="com.aaa.bbb.viewmodel.SystemSettingsViewModel"
name="systemSettings"
</variable>
</data>
<TextView
android:gravity="end"
android:id="@+id/tv_logging"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:layout_width="wrap_content"
android:onClick="@{() -> systemSettings.sendLogs()}"
android:text="@string/enable_logs"
android:textAlignment="viewEnd" />