android按钮点击事件没有反应,DataBinding点击事件没有反应

1.  在布局文件中:

name="presenter"

type="com.xogrp.planner.user.contract.UserProfileContract.Presenter" />

android:id="@+id/iv_cover_photo"

android:layout_width="0dp"

android:layout_height="0dp"

android:importantForAccessibility="no"

android:onClick="@{()->handlers.showEditPhotoDialog()}"

android:contentDescription="@string/content_description_edit_photo"

android:scaleType="centerCrop"

android:src="@drawable/tk_big_placeholder"

app:couplePhoto="@{viewModel.couplePhotoUrl}"

app:layout_constraintDimensionRatio="1:1"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent" />

2. 在Fragment 文件中:

override fun onPlannerCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {

Timber.tag(LIFECYCLE_TAG).d("UserProfileFragment.onPlannerCreateView $savedInstanceState")

mViewModel = UserProfileViewModel(user)

mDataBinding = DataBindingUtil.inflate(inflater, getLayoutRes(), container, false)

mDataBinding.viewModel =mViewModel

mDataBinding.presenter =mPresenter

mDataBinding.handlers = Handlers()

if (savedInstanceState !=null) {

mViewModel.memberPayload =savedInstanceState.getSerializable(KEY_PAYLOAD)as MemberPayload?

?: MemberPayload()

}

return mDataBinding.root

}

你可能感兴趣的:(android按钮点击事件没有反应,DataBinding点击事件没有反应)