嗨,这就是我应该做的;使用QuickAction和github库,我可以执行类似的操作,但是菜单显示在底部而不是右侧。有什么办法吗?谢谢
这是我的代码,在其中设置菜单按钮的侦听器:
btnMenuUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//tooltipWindow.showToolTip(view, Gravity.RIGHT);
QuickAction.setDefaultColor(ResourcesCompat.getColor(getResources(), R.color.disable_switch, null));
QuickAction.setDefaultTextColor(Color.WHITE);
ActionItem profileItem = new ActionItem(ID_PROFILE, getString(R.string.menu_item_profile), -1);
ActionItem notificationsItem = new ActionItem(ID_NOTIFICATIONS, getString(R.string.menu_item_notifications), -1);
ActionItem logoutItem = new ActionItem(ID_LOGOUT, getString(R.string.menu_item_logout), -1);
profileItem.setSticky(true);
notificationsItem.setSticky(true);
logoutItem.setSticky(true);
quickAction = new QuickAction(getApplicationContext(), QuickAction.VERTICAL);
quickAction.setTextColor(getResources().getColor(R.color.black));
quickAction.setColorRes(R.color.disable_switch);
quickAction.setDividerColor(R.color.secondary_grey);
quickAction.setEnabledDivider(true);
quickAction.addActionItem(profileItem);
quickAction.addActionItem(notificationsItem);
quickAction.addActionItem(logoutItem);
quickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() { //FUNZIONA
@Override
public void onItemClick(ActionItem item) {
int myId = item.getActionId();
switch (myId) {
case 1:
//ADD INTENT TO GO PROFILE
break;
case 2:
//ADD INTENT TO NOTIFICATIONS
break;
case 3:
Intent intentLogout = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(intentLogout);
finish();
break;
}
}
});
quickAction.show(view);