接下来是问题,当我输入ImageView
mIV_WishItem
“heart”时,导致onClick
背景ImageView
mIV_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>
请帮我找到解决方案
答案 0 :(得分:0)
您需要在ImageView中添加属性(mIV_WishItem):
android:focusable="true"
android:focusableInTouchMode="true"
Viewholder项目本身是可聚焦的,因此我们需要将注意力集中在imageview上。之后我们可以启用点击图片查看。