Recyclerview ViewHolder不可单击-android
RecyclerView Viewholder单击不起作用。我正在为recyclerview使用LinearLayoutManager。recyclerview viewholder内未触发clcik事件。我错过什么了吗?这是我的取景器Recyclerview ViewHolder不可单击-android,android,android-recyclerview,Android,Android Recyclerview,RecyclerView Viewholder单击不起作用。我正在为recyclerview使用LinearLayoutManager。recyclerview viewholder内未触发clcik事件。我错过什么了吗?这是我的取景器 public class FeedViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ @Bind(R.id.imgNewUser) C
public class FeedViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
@Bind(R.id.imgNewUser) CircularImageView imgUser;
@Bind(R.id.txtUserNameNewUser) TextView txtUserNameNewUser;
@Bind(R.id.txtNewUserPostCount) TextView txtNewUserPostCount;
@Bind(R.id.btnFollowNewUser) Button btnFollowNewUser;
public FeedViewHolder(View view) {
super(view);
view.setOnClickListener(this);
ButterKnife.bind(this,view);
}
@Override
public void onClick(View v){
Toast.makeText(mContext,"Hello",Toast.LENGTH_SHORT);
onFollowListener.onFollow(getAdapterPosition());
}
}
以及膨胀的行布局
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/tools"
card_view:cardElevation="3dp"
android:clickable="true"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true">
<LinearLayout
android:layout_toLeftOf="@+id/btnFollowNewUser"
android:orientation="horizontal"
android:layout_margin="10dp"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.petmire.petmireapp.common.CircularImageView
android:id="@+id/imgNewUser"
android:src="@drawable/ic_launcher"
android:layout_width="50dp"
android:layout_height="50dp"
app:border_width="0.5dp"
app:border_color="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txtUserNameNewUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textSize="17sp"
android:textColor="@color/colorPrimaryDark"
android:fontFamily="sans-serif-light"
android:text="Petmireapp1"/>
<TextView
android:id="@+id/txtNewUserPostCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:textSize="14sp"
android:textColor="@color/colorPrimary"
android:fontFamily="sans-serif-light"
android:text="26 Posts"/>
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/btnFollowNewUser"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:fontFamily="sans-serif-light"
android:text="Follow"
android:clickable="true"
android:background="@drawable/btn_follow_shape"
android:layout_marginRight="10dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
请帮助我解决此问题。请参阅此处,了解回收器视图单击“我们不能像我所实现的那样处理onclick吗?”?它适用于StaggedGridLayoutManager,但不适用于LinearLayoutManager我尚未验证StaggedGridLayoutManager您可以尝试并验证参考此处查看回收器视图单击我们不能像我所实现的那样处理一次单击吗?它适用于StaggedGridLayoutManager,但不适用于LinearLayoutManager我尚未验证StaggedGridLayoutManager,您可以尝试验证