ActionBar PopuMenu
PopupMenu
popupmenu可以非常方便得实现在指定view下弹出一个菜单,实现类似ActionBar中的效果.
public void showPopupMenu(View view){
final PopupAdapter adapter = (PopupAdapter) getListAdapter();
final String item = (String) view.getTag();
PopupMenu popup = new PopupMenu(getActivity(), view);
popup.getMenuInflater().inflate(R.menu.popup, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
switch (menuItem.getItemId()){
case R.id.menu_remove:
adapter.remove(item);
return true;
}
return false;
}
});
popup.show();
}