Wednesday , June 22 2022

Create Options Menu for RecyclerView Item Tutorial – Android Coding by DMTechnolab

The package The trap.Simplified coding.recyclerviewoptionsmenu;

Import Android.Content.Context;

Import Android.Content.Dialog interface;

Import Android.Support.v7.App.AlertDialog;

Import Android.Support.v7.Widget.Flash list;

Import Android.Support.v7.Widget.RecyclerView;

Import Android.Opinion.Layout;

Import item;

Import Android.Opinion.Opinion;

Import Android.Opinion.Viewgroup;

Import Android.Widget.text view;

Import Java.Useful.The list;

/ **

* Created by Belal on 29/09/16.

* /

public class CustomAdapter Is spread RecyclerView.Adapter<CustomAdapter.View folder> {{

Private The list The list;

Private Context mCtx;

public CustomAdapter()The list The list, Context mCtx) {{

this.The list = The list;

this.mCtx = mCtx;



public View folder onCreateViewHolder()Viewgroup Parent, int View) {{

Opinion v = Layout.From()Parent.getContext()))

.To inflate()R.Layout.Baggage catalog, Parent, false);

The return New View folder()v);



public Zero onBindViewHolder()The last CustomAdapter.View folder The holder, int Post) {{

My list My list = The list.get()Post);

The holder.textViewHead.Settext()My list.Gatehead()));

The holder.textViewDesc.Settext()My list.Getdesk()));

The holder.Button view.setOnClickListener()New Opinion.OnClickListener()) {{

@ Override

public Zero on click()Opinion Opinion) {{

// create a popup menu

Flash list Pop up = New Flash list()mCtx, The holder.Button view);

// xml resource moving menu

Pop up.To inflate()R.Menu.Option_menu);

// add click listener

Pop up.setOnMenuItemClickListener()New Flash list.Onmenuytem Klicksteiner()) {{


public Boolean click onMenuItem()menu item item) {{

to switch ()item.getItemId())) {{

matter R.Id.Menu 1:

// click handle menu 1


matter R.Id.Menu 2:

// click handle menu 2


matter R.Id.Menu 3:

// click handle menu 3



The return false;



// displaying popup

Pop up.Display());





public int getItemCount()) {{

The return The list.Shape());


public class View folder Is spread RecyclerView.View folder {{

public text view textViewHead;

public text view textViewDesc;

public text view Button view;

public View folder()Opinion Item view) {{


textViewHead = ()text view) Item view.findViewById()R.Id.textViewHead);

textViewDesc = ()text view) Item view.findViewById()R.Id.textViewDesc);

Button view = ()text view) Item view.findViewById()R.Id.textViewOptions);




Source link

About dmtechnolab

Check Also

Simplified Coding

Android Hilt Tutorial – Injecting Dependencies with Hilt – Android Coding by DMTechnolab

You are welcome Android Hilt tutorial. I hope you all are aware of it Dependency …

Leave a Reply

Your email address will not be published. Required fields are marked *