Skip to content Skip to sidebar Skip to footer

My Interface Class Don't Work When I Call It From A Fragment

I'm trying to implement this code in my project but is not working RecyclerView: how to catch the onClick on an ImageView?: I've implemented a interface to handle onclick imageview

Solution 1:

If you want the fragment to listen for the actions happening in the adapter then you need to register it as the listener for the events happening in the adapter(by implementing the interface and passing the fragment as a listener):

public class MainTimeline extends Fragment implements RecyclerViewClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // you don't need a private RecyclerViewClickListener listener; reference as you have the fragment itself
        mAdapter = new MainTimelineRecyclerAdapter(getActivity(), dbList, this); 
    }
    // implement the methods from the interface
}

Post a Comment for "My Interface Class Don't Work When I Call It From A Fragment"