Put that 3 dot image and on click of that image use the following,
//creating a popup menu
PopupMenu popup = new PopupMenu(context, holder.addresslistmenu);
//inflating menu from xml resource
popup.inflate(R.menu.addressmenu);
//adding click listener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.addresslistupdatemenu:
yourfunction()
break;
}
return false;
}
});
//displaying the popup
popup.show();
Add the menu item in res-menu,
example ::
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/addresslistupdatemenu"
android:title="Update" />
<item
android:id="@+id/addresslistdeletemenu"
android:title="Delete" />
</menu>
Image click is in onBindViewHolder in the adapter.
holder.image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// PopupMenu function here
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…