how to create popup menu in android cardview
<p>I want to create popup menu with edit and delete option on card view I have tried the below code but I am getting force close at <code>popup.show();</code>with fatal exception <code>onclick</code> of <code>imageview</code>. What should i do to create popup menu on <code>cardview</code>?</p>

<pre><code>public class ShipRecyclerAdapter extends RecyclerView.Adapter&lt;ShipRecyclerAdapter.ViewHolder&gt; {

public static final String PRODUCTID = "PRODUCTID";
public static final String PRODUCTNAME = "PRODUCTNAME";

List&lt;CustDatabaseModel&gt; dbCustList;
static Context context;
public ImageView btndots;

ShipRecyclerAdapter(Context context, List&lt;CustDatabaseModel&gt; dbCustList ){
    this.dbCustList = new ArrayList&lt;CustDatabaseModel&gt;();
    this.context = context;
    this.dbCustList = dbCustList;

}

@Override
public ShipRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    View itemLayoutView = LayoutInflater.from(parent.getContext()).inflate(
            R.layout.address_list, null);

    // create ViewHolder

    ViewHolder viewHolder = new ViewHolder(itemLayoutView);
    return viewHolder;
}

@Override
public void onBindViewHolder(ShipRecyclerAdapter.ViewHolder holder, final int position) {

    holder.address.setText(dbCustList.get(position).getaddress());
    holder.city.setText(dbCustList.get(position).getcity());
    holder.state.setText(dbCustList.get(position).getstate());
    holder.zipcode.setText(dbCustList.get(position).getzip());

  final String adr=dbCustList.get(position).getaddress().toString();

    holder.btndots.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            PopupMenu popup = new PopupMenu(context, btndots);
            //Inflating the Popup using xml file
            popup.getMenuInflater().inflate(R.menu.popup_menu, popup.getMenu());

            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                public boolean onMenuItemClick(MenuItem item) {
                    Intent i;
                    if ((item.getTitle().toString()).equalsIgnoreCase("Edit")) {
                        Toast.makeText(ShipRecyclerAdapter.context, "you have clicked Menu image ", Toast.LENGTH_LONG).show();

                    } else if ((item.getTitle().toString()).equalsIgnoreCase("Delete")) {
                        Toast.makeText(ShipRecyclerAdapter.context, "you have clicked Menu image ", Toast.LENGTH_LONG).show();
                    }
                    return true;
                }
            });

            popup.show();
        }
    });



    //closing the setOnClickListener method



}

@Override
public int getItemCount() {
    return dbCustList.size();
}

public class ViewHolder extends RecyclerView.ViewHolder {

    public TextView state,address,city,zipcode;
    public ImageView btndots;



    public ViewHolder(View itemLayoutView) {
        super(itemLayoutView);
        address = (TextView) itemLayoutView.findViewById(R.id.textViewAddress);
        city = (TextView)itemLayoutView.findViewById(R.id.textViewCity);
        zipcode = (TextView)itemLayoutView.findViewById(R.id.textViewZipcode);
        state = (TextView)itemLayoutView.findViewById(R.id.textViewState);
        this.btndots = (ImageView)itemLayoutView.findViewById(R.id.cmenu);


    }



}
</code></pre>

<p>}` </p>