I would like to have pop up menu, when I click on the 3 dots area in a ListView
row.
I know its a bit late and you probably may have found a solution but i just came across your question and here's my solution...
Below is my code of the getView method of the Adapter class...
@Override
public View getView(int p, View convertView, ViewGroup parent)
{
final ViewHolder holder;
if (convertView == null)
{
holder = new ViewHolder();
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.d_item, null);
holder.dHeading = (TextView) convertView.findViewById(R.id.txt);
holder.ds = (TextView) convertView.findViewById(R.id.txt1);
holder.options = (ImageView)convertView.findViewById(R.id.dPopupMenu);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
holder.dHeading.setText(DList.get(p).getDHeading());
holder.ds.setText(DList.get(p).getDs());
holder.options.setOnClickListener( new OnClickListener()
{
@Override
public void onClick(View v)
{
final PopupMenu popmenu = new PopupMenu(context, holder.options);
popmenu.getMenuInflater().inflate(R.menu.dua_popup_menu, popmenu.getMenu());
popmenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener()
{
public boolean onMenuItemClick(MenuItem item)
{
Toast.makeText(context, "You Clicked : " + item.getTitle(), Toast.LENGTH_SHORT).show();
return true;
}
});
popmenu.show();
}
});
return convertView;
}