Android 使用两个imageView onClick是否正确?

Android 使用两个imageView onClick是否正确?,android,android-layout,Android,Android Layout,下一个问题是,当我输入ImageViewmIV\u-WishItem心脏时,onClickbackgroundImageViewmIV\u-WishItem 此按钮的代码如下: holder.mIV_WishItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) {

下一个问题是,当我输入
ImageView
mIV\u-WishItem
心脏时,
onClick
background
ImageView
mIV\u-WishItem

此按钮的代码如下:

            holder.mIV_WishItem.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    setFavorites(holder, sectionsItem, true);
                }
            });

            holder.mIV_pictureGoodsItem.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    SectionsItem sectionsItem = sectionsItems.get(position);
                    sectionItemId = sectionsItem.getId();

                    getDataForItemDetails(mContext);
                }
            });
和xml用于此按钮

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="@dimen/_200sdp"
    >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="end"
        >

        <ImageView
            android:id="@+id/iV_Wish"
            android:layout_width="@dimen/bottom_navigation_icon"
            android:layout_height="@dimen/bottom_navigation_icon"
            />
    </LinearLayout>

    <ImageView
        android:id="@+id/iV_pictureGoods_Item"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal"
        />
</RelativeLayout>


请帮助我找到解决方案

您需要在ImageView(mIV_WishItem)中添加属性:

Viewholder项本身是可聚焦的,所以我们需要在imageview上设置焦点。之后,我们可以启用单击imageview

android:focusable="true"
android:focusableInTouchMode="true"