I'm using a RecyclerView
to display some data. For each item I have a custom layout which holds beside some text views a RecyclerView
:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="180dp"
android:layout_height="45dp"
android:id="@+id/recycler_view"/>
//Other text views
</RelativeLayout>
This is my adapter class:
class UserViewHolder extends RecyclerView.ViewHolder {
View itemView;
RecyclerView recyclerView;
UserViewHolder(View itemView) {
super(itemView);
this.itemView = itemView;
recyclerView = itemView.findViewById(R.id.recycler_view);
}
void bind(User user) {
itemView.setOnClickListener(view -> {
//Move to user Activity
});
UserAdapter adapter = new UserAdapter(user.list);
recyclerView.setAdapter(adapter);
itemView.bringToFront(); //Doesn't work!!!
}
}
I have set on click listener on the entire itemView
so I can be redirected to user's activity. The problem is that when I click on the elements that exist in the RecyclerView
, I'm not redirected. I tried to bring the itemView
in front of the RecyclerView
but with no luck. How should I do so I can be redirected to the user activity even if I click on the RecyclerView
? Thanks!
Edit:
This is how my itemView layout looks like:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:clickable="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
//One TextView
//One ImageView
//One RecyclerView
</RelativeLayout>
</android.support.v7.widget.CardView>
This is an image of it: