What is the PopupMenu equivalent in ActionBarSherlock? I can't seem to find it. Its API 11, why is it absent?
The Class MenuPopupHelper pretty much does the job. I didn't find an easy way to listen for Item Clicks though, so I implemented this class that derives from MenuPopupHelper:
public class MenuPopup extends MenuPopupHelper {
OnMenuItemClickListener onMenuItemClickListener;
public MenuPopup(Context context, MenuBuilder menu, View anchorView) {
super(context, menu, anchorView);
}
public void setOnMenuItemClickListener(
OnMenuItemClickListener onMenuItemClickListener) {
this.onMenuItemClickListener = onMenuItemClickListener;
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
super.onItemClick(parent, view, position, id);
if (onMenuItemClickListener != null)
onMenuItemClickListener.onMenuItemClick(position);
}
public interface OnMenuItemClickListener{
public void onMenuItemClick(int itemID);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With