Use the event of a recyclerview in a Fragment












0















Good morning friends,
My problem is the following. I have a cardview with a button, i catch the button event in the recyclerview, but I would like to catch the button event in the fragment that contains the recyclerview.



@Override
public void onBindViewHolder(@NonNull final MyViewHolder myViewHolder, final int i) {


myViewHolder.imagen.setImageResource(mData.get(i).getImage());
myViewHolder.title.setText(mData.get(i).getTitel());



myViewHolder.button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context,"ok"+i,Toast.LENGTH_SHORT).show();


}
});



}


I need to use the event here.



@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

view = inflater.inflate(R.layout.fragment_form4, container, false);





list = new ArrayList<>();
list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));


RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview);
RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapterFotoForm4);




return view;
}


Thanks in advance.










share|improve this question



























    0















    Good morning friends,
    My problem is the following. I have a cardview with a button, i catch the button event in the recyclerview, but I would like to catch the button event in the fragment that contains the recyclerview.



    @Override
    public void onBindViewHolder(@NonNull final MyViewHolder myViewHolder, final int i) {


    myViewHolder.imagen.setImageResource(mData.get(i).getImage());
    myViewHolder.title.setText(mData.get(i).getTitel());



    myViewHolder.button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Toast.makeText(context,"ok"+i,Toast.LENGTH_SHORT).show();


    }
    });



    }


    I need to use the event here.



    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {

    view = inflater.inflate(R.layout.fragment_form4, container, false);





    list = new ArrayList<>();
    list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
    list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
    list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
    list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
    list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));


    RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview);
    RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(adapterFotoForm4);




    return view;
    }


    Thanks in advance.










    share|improve this question

























      0












      0








      0








      Good morning friends,
      My problem is the following. I have a cardview with a button, i catch the button event in the recyclerview, but I would like to catch the button event in the fragment that contains the recyclerview.



      @Override
      public void onBindViewHolder(@NonNull final MyViewHolder myViewHolder, final int i) {


      myViewHolder.imagen.setImageResource(mData.get(i).getImage());
      myViewHolder.title.setText(mData.get(i).getTitel());



      myViewHolder.button.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      Toast.makeText(context,"ok"+i,Toast.LENGTH_SHORT).show();


      }
      });



      }


      I need to use the event here.



      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {

      view = inflater.inflate(R.layout.fragment_form4, container, false);





      list = new ArrayList<>();
      list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
      list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
      list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
      list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
      list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));


      RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview);
      RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list);
      recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
      recyclerView.setAdapter(adapterFotoForm4);




      return view;
      }


      Thanks in advance.










      share|improve this question














      Good morning friends,
      My problem is the following. I have a cardview with a button, i catch the button event in the recyclerview, but I would like to catch the button event in the fragment that contains the recyclerview.



      @Override
      public void onBindViewHolder(@NonNull final MyViewHolder myViewHolder, final int i) {


      myViewHolder.imagen.setImageResource(mData.get(i).getImage());
      myViewHolder.title.setText(mData.get(i).getTitel());



      myViewHolder.button.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
      Toast.makeText(context,"ok"+i,Toast.LENGTH_SHORT).show();


      }
      });



      }


      I need to use the event here.



      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {

      view = inflater.inflate(R.layout.fragment_form4, container, false);





      list = new ArrayList<>();
      list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
      list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
      list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
      list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
      list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));


      RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview);
      RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list);
      recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
      recyclerView.setAdapter(adapterFotoForm4);




      return view;
      }


      Thanks in advance.







      java android android-studio android-recyclerview android-cardview






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 25 '18 at 9:03









      FulanoFulano

      153




      153
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You can have a callback(interface) to communicate between adapter and fragment. For example consider following callback (you can have it as a separate file):



          public interface OnClickCallback {
          void onClicked(int position);
          }


          In your fragment implement it so you will have following override method



          @Override
          public void onClicked(int position){
          // you will be retriving the clicked position
          }


          In your fragment create an instance OnClickCallback and pass it to adapter so that in on setOnClickListener method of adapter you can communicate with fragment using callback.



          private OnClickCallback onClickCallback;

          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {

          view = inflater.inflate(R.layout.fragment_form4, container, false);

          onClickCallback = this;



          list = new ArrayList<>();
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));


          RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview);
          RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list);
          recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
          recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

          return view;
          }


          There in adapter constructor :



          public Adapter(List<String> yourList, OnClickCallback itemClickCallback) {
          this.yourList = yourList;
          this.itemClickCallback = itemClickCallback;
          }


          In setOnClickListener you can call it as follows :



          myViewHolder.button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
          itemClickCallback.onClicked(position);
          }
          });





          share|improve this answer
























          • Thank you very much for your answer. could you tell me if I am doing wrong with the adapter?

            – Fulano
            Nov 25 '18 at 13:05











          • Thank you very much for your answer. could you tell me if I am doing wrong with the adapter? here I have to implement the adapter. public class RecyclerViewAdapterFotoForm4 extends RecyclerView.Adapter<RecyclerViewAdapterFotoForm4.MyViewHolder> { OnClickCallback itemClickCallback; Context context; List<POJOcarviewFotoForm4> mData; View view; public RecyclerViewAdapterFotoForm4(List<POJOcarviewFotoForm4> list, OnClickCallback itemClickCallback) { this.mData = list; this.itemClickCallback = itemClickCallback; }

            – Fulano
            Nov 25 '18 at 13:13











          • I can not enter two parameters here RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview); RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

            – Fulano
            Nov 25 '18 at 13:15











          • Please refer this link for recycler view clear understanding : androidhive.info/2016/01/android-working-with-recycler-view

            – Raj
            Nov 25 '18 at 13:53













          • Thanks for the help

            – Fulano
            Nov 25 '18 at 14:50











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466039%2fuse-the-event-of-a-recyclerview-in-a-fragment%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You can have a callback(interface) to communicate between adapter and fragment. For example consider following callback (you can have it as a separate file):



          public interface OnClickCallback {
          void onClicked(int position);
          }


          In your fragment implement it so you will have following override method



          @Override
          public void onClicked(int position){
          // you will be retriving the clicked position
          }


          In your fragment create an instance OnClickCallback and pass it to adapter so that in on setOnClickListener method of adapter you can communicate with fragment using callback.



          private OnClickCallback onClickCallback;

          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {

          view = inflater.inflate(R.layout.fragment_form4, container, false);

          onClickCallback = this;



          list = new ArrayList<>();
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));


          RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview);
          RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list);
          recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
          recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

          return view;
          }


          There in adapter constructor :



          public Adapter(List<String> yourList, OnClickCallback itemClickCallback) {
          this.yourList = yourList;
          this.itemClickCallback = itemClickCallback;
          }


          In setOnClickListener you can call it as follows :



          myViewHolder.button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
          itemClickCallback.onClicked(position);
          }
          });





          share|improve this answer
























          • Thank you very much for your answer. could you tell me if I am doing wrong with the adapter?

            – Fulano
            Nov 25 '18 at 13:05











          • Thank you very much for your answer. could you tell me if I am doing wrong with the adapter? here I have to implement the adapter. public class RecyclerViewAdapterFotoForm4 extends RecyclerView.Adapter<RecyclerViewAdapterFotoForm4.MyViewHolder> { OnClickCallback itemClickCallback; Context context; List<POJOcarviewFotoForm4> mData; View view; public RecyclerViewAdapterFotoForm4(List<POJOcarviewFotoForm4> list, OnClickCallback itemClickCallback) { this.mData = list; this.itemClickCallback = itemClickCallback; }

            – Fulano
            Nov 25 '18 at 13:13











          • I can not enter two parameters here RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview); RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

            – Fulano
            Nov 25 '18 at 13:15











          • Please refer this link for recycler view clear understanding : androidhive.info/2016/01/android-working-with-recycler-view

            – Raj
            Nov 25 '18 at 13:53













          • Thanks for the help

            – Fulano
            Nov 25 '18 at 14:50
















          0














          You can have a callback(interface) to communicate between adapter and fragment. For example consider following callback (you can have it as a separate file):



          public interface OnClickCallback {
          void onClicked(int position);
          }


          In your fragment implement it so you will have following override method



          @Override
          public void onClicked(int position){
          // you will be retriving the clicked position
          }


          In your fragment create an instance OnClickCallback and pass it to adapter so that in on setOnClickListener method of adapter you can communicate with fragment using callback.



          private OnClickCallback onClickCallback;

          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {

          view = inflater.inflate(R.layout.fragment_form4, container, false);

          onClickCallback = this;



          list = new ArrayList<>();
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));


          RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview);
          RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list);
          recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
          recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

          return view;
          }


          There in adapter constructor :



          public Adapter(List<String> yourList, OnClickCallback itemClickCallback) {
          this.yourList = yourList;
          this.itemClickCallback = itemClickCallback;
          }


          In setOnClickListener you can call it as follows :



          myViewHolder.button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
          itemClickCallback.onClicked(position);
          }
          });





          share|improve this answer
























          • Thank you very much for your answer. could you tell me if I am doing wrong with the adapter?

            – Fulano
            Nov 25 '18 at 13:05











          • Thank you very much for your answer. could you tell me if I am doing wrong with the adapter? here I have to implement the adapter. public class RecyclerViewAdapterFotoForm4 extends RecyclerView.Adapter<RecyclerViewAdapterFotoForm4.MyViewHolder> { OnClickCallback itemClickCallback; Context context; List<POJOcarviewFotoForm4> mData; View view; public RecyclerViewAdapterFotoForm4(List<POJOcarviewFotoForm4> list, OnClickCallback itemClickCallback) { this.mData = list; this.itemClickCallback = itemClickCallback; }

            – Fulano
            Nov 25 '18 at 13:13











          • I can not enter two parameters here RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview); RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

            – Fulano
            Nov 25 '18 at 13:15











          • Please refer this link for recycler view clear understanding : androidhive.info/2016/01/android-working-with-recycler-view

            – Raj
            Nov 25 '18 at 13:53













          • Thanks for the help

            – Fulano
            Nov 25 '18 at 14:50














          0












          0








          0







          You can have a callback(interface) to communicate between adapter and fragment. For example consider following callback (you can have it as a separate file):



          public interface OnClickCallback {
          void onClicked(int position);
          }


          In your fragment implement it so you will have following override method



          @Override
          public void onClicked(int position){
          // you will be retriving the clicked position
          }


          In your fragment create an instance OnClickCallback and pass it to adapter so that in on setOnClickListener method of adapter you can communicate with fragment using callback.



          private OnClickCallback onClickCallback;

          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {

          view = inflater.inflate(R.layout.fragment_form4, container, false);

          onClickCallback = this;



          list = new ArrayList<>();
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));


          RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview);
          RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list);
          recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
          recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

          return view;
          }


          There in adapter constructor :



          public Adapter(List<String> yourList, OnClickCallback itemClickCallback) {
          this.yourList = yourList;
          this.itemClickCallback = itemClickCallback;
          }


          In setOnClickListener you can call it as follows :



          myViewHolder.button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
          itemClickCallback.onClicked(position);
          }
          });





          share|improve this answer













          You can have a callback(interface) to communicate between adapter and fragment. For example consider following callback (you can have it as a separate file):



          public interface OnClickCallback {
          void onClicked(int position);
          }


          In your fragment implement it so you will have following override method



          @Override
          public void onClicked(int position){
          // you will be retriving the clicked position
          }


          In your fragment create an instance OnClickCallback and pass it to adapter so that in on setOnClickListener method of adapter you can communicate with fragment using callback.



          private OnClickCallback onClickCallback;

          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {

          view = inflater.inflate(R.layout.fragment_form4, container, false);

          onClickCallback = this;



          list = new ArrayList<>();
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));
          list.add(new POJOcarviewFotoForm4(R.drawable.ic_person_black_24dp,"Picture"));


          RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview);
          RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list);
          recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
          recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

          return view;
          }


          There in adapter constructor :



          public Adapter(List<String> yourList, OnClickCallback itemClickCallback) {
          this.yourList = yourList;
          this.itemClickCallback = itemClickCallback;
          }


          In setOnClickListener you can call it as follows :



          myViewHolder.button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
          itemClickCallback.onClicked(position);
          }
          });






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 25 '18 at 9:28









          RajRaj

          14216




          14216













          • Thank you very much for your answer. could you tell me if I am doing wrong with the adapter?

            – Fulano
            Nov 25 '18 at 13:05











          • Thank you very much for your answer. could you tell me if I am doing wrong with the adapter? here I have to implement the adapter. public class RecyclerViewAdapterFotoForm4 extends RecyclerView.Adapter<RecyclerViewAdapterFotoForm4.MyViewHolder> { OnClickCallback itemClickCallback; Context context; List<POJOcarviewFotoForm4> mData; View view; public RecyclerViewAdapterFotoForm4(List<POJOcarviewFotoForm4> list, OnClickCallback itemClickCallback) { this.mData = list; this.itemClickCallback = itemClickCallback; }

            – Fulano
            Nov 25 '18 at 13:13











          • I can not enter two parameters here RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview); RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

            – Fulano
            Nov 25 '18 at 13:15











          • Please refer this link for recycler view clear understanding : androidhive.info/2016/01/android-working-with-recycler-view

            – Raj
            Nov 25 '18 at 13:53













          • Thanks for the help

            – Fulano
            Nov 25 '18 at 14:50



















          • Thank you very much for your answer. could you tell me if I am doing wrong with the adapter?

            – Fulano
            Nov 25 '18 at 13:05











          • Thank you very much for your answer. could you tell me if I am doing wrong with the adapter? here I have to implement the adapter. public class RecyclerViewAdapterFotoForm4 extends RecyclerView.Adapter<RecyclerViewAdapterFotoForm4.MyViewHolder> { OnClickCallback itemClickCallback; Context context; List<POJOcarviewFotoForm4> mData; View view; public RecyclerViewAdapterFotoForm4(List<POJOcarviewFotoForm4> list, OnClickCallback itemClickCallback) { this.mData = list; this.itemClickCallback = itemClickCallback; }

            – Fulano
            Nov 25 '18 at 13:13











          • I can not enter two parameters here RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview); RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

            – Fulano
            Nov 25 '18 at 13:15











          • Please refer this link for recycler view clear understanding : androidhive.info/2016/01/android-working-with-recycler-view

            – Raj
            Nov 25 '18 at 13:53













          • Thanks for the help

            – Fulano
            Nov 25 '18 at 14:50

















          Thank you very much for your answer. could you tell me if I am doing wrong with the adapter?

          – Fulano
          Nov 25 '18 at 13:05





          Thank you very much for your answer. could you tell me if I am doing wrong with the adapter?

          – Fulano
          Nov 25 '18 at 13:05













          Thank you very much for your answer. could you tell me if I am doing wrong with the adapter? here I have to implement the adapter. public class RecyclerViewAdapterFotoForm4 extends RecyclerView.Adapter<RecyclerViewAdapterFotoForm4.MyViewHolder> { OnClickCallback itemClickCallback; Context context; List<POJOcarviewFotoForm4> mData; View view; public RecyclerViewAdapterFotoForm4(List<POJOcarviewFotoForm4> list, OnClickCallback itemClickCallback) { this.mData = list; this.itemClickCallback = itemClickCallback; }

          – Fulano
          Nov 25 '18 at 13:13





          Thank you very much for your answer. could you tell me if I am doing wrong with the adapter? here I have to implement the adapter. public class RecyclerViewAdapterFotoForm4 extends RecyclerView.Adapter<RecyclerViewAdapterFotoForm4.MyViewHolder> { OnClickCallback itemClickCallback; Context context; List<POJOcarviewFotoForm4> mData; View view; public RecyclerViewAdapterFotoForm4(List<POJOcarviewFotoForm4> list, OnClickCallback itemClickCallback) { this.mData = list; this.itemClickCallback = itemClickCallback; }

          – Fulano
          Nov 25 '18 at 13:13













          I can not enter two parameters here RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview); RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

          – Fulano
          Nov 25 '18 at 13:15





          I can not enter two parameters here RecyclerView recyclerView=(RecyclerView)view.findViewById(R.id.form4_recyclerview); RecyclerViewAdapterFotoForm4 adapterFotoForm4=new RecyclerViewAdapterFotoForm4(getContext(),list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setAdapter(adapterFotoForm4, onClickCallback);

          – Fulano
          Nov 25 '18 at 13:15













          Please refer this link for recycler view clear understanding : androidhive.info/2016/01/android-working-with-recycler-view

          – Raj
          Nov 25 '18 at 13:53







          Please refer this link for recycler view clear understanding : androidhive.info/2016/01/android-working-with-recycler-view

          – Raj
          Nov 25 '18 at 13:53















          Thanks for the help

          – Fulano
          Nov 25 '18 at 14:50





          Thanks for the help

          – Fulano
          Nov 25 '18 at 14:50


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466039%2fuse-the-event-of-a-recyclerview-in-a-fragment%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Lallio

          Unable to find Lightning Node

          Futebolista