Idea on implementing the following pop up menu in ListView

后端 未结 3 1704
孤街浪徒
孤街浪徒 2021-02-04 21:34

I would like to have pop up menu, when I click on the 3 dots area in a ListView row.

\"enter

3条回答
  •  悲&欢浪女
    2021-02-04 22:35

    1. You can use ImageView to display image with 3 dots.

    2. There are two ways for popupmenu

      a) Use some layouts and make them visible/gone

      b) Use PopupWindow.

    here is sample code for PopupWindow

    PopupWindow popupWindow = new PopupWindow(context);
    
    View popUpView = View.inflate(activity, linearlayout, null);
    popUpView.setBackgroundColor(Color.TRANSPARENT);
    mpopup.setContentView(popUpView);
    mpopup.setHeight(LayoutParams.WRAP_CONTENT);
    mpopup.setWidth(LayoutParams.WRAP_CONTENT);
    mpopup.setFocusable(true);
    mpopup.setBackgroundDrawable(activity.getResources().getDrawable(R.drawable.transperent));
    mpopup.setOutsideTouchable(true);
    mpopup.setAnimationStyle(R.anim.slide_out_up);
    mpopup.showAtLocation(popUpView, Gravity.TOP, activity.getResources()
                .getInteger(R.integer.log_out_popup_x), activity.getResources()
                .getInteger(R.integer.log_out_popup_y));
    

提交回复
热议问题