Skip to content
Advertisement

How can I do an Android retrofit 2 recyclerview interface?

Here is my code.

My adapter:

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.myviewholder> {
    List<ResponseModel> data;

    private final IOtobusSaatleriInterface iOtobusSaatleriInterface;

    public MyAdapter(List<ResponseModel> data, IOtobusSaatleriInterface iOtobusSaatleriInterface) {

        this.data = data;
        this.iOtobusSaatleriInterface = iOtobusSaatleriInterface;
    }
}

And my interface:

public interface IOtobusSaatleriInterface {
    void onItemClick(int position);
}

This is where I am failing. Here is my failing home fragment page. Where is the problem? This is my fail and my fail home fragment page. where is the my fail ?

Advertisement

Answer

Instead of this, write something like HomeFragment.this.

I assume that HomeFragment implements IOtobusSaatleriInterface.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement