自定义的界面底部向上弹出的PopupWindow

来源:互联网 发布:mac 如何将lrc嵌入mp3 编辑:程序博客网 时间:2024/04/29 16:14

public class BottomPopWin extends PopupWindow {

  private final TextView tvTotaDoneNums;  private final GridView gvSelectNum;  private View view;  public BottomPopWin(Activity cx) {    DisplayMetrics dm = new DisplayMetrics();    cx.getWindowManager().getDefaultDisplay().getMetrics(dm);    Rect rect = new Rect();    cx.getWindow().getDecorView().getWindowVisibleDisplayFrame(rect);    int top = rect.top;    View v = cx.getWindow().findViewById(Window.ID_ANDROID_CONTENT);    int top2 = v.getTop();    this.view = LayoutInflater.from(cx).inflate(R.layout.bootomdialog, null);    tvTotaDoneNums = (TextView) view.findViewById(R.id.tv_dialog_btm_num_done);    gvSelectNum = (GridView) view.findViewById(R.id.gv_nums);    this.setOutsideTouchable(true);    this.view.setOnTouchListener(new View.OnTouchListener() {      public boolean onTouch(View v, MotionEvent event) {        int height = view.findViewById(R.id.ll_dialog_btm_content).getTop();        int y = (int) event.getY();        if (event.getAction() == MotionEvent.ACTION_UP) {          if (y < height) {            dismiss();          }        }        return true;      }    });    this.setContentView(this.view);    this.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);    this.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);    this.setFocusable(true);    ColorDrawable dw = new ColorDrawable(0x50000000);    this.setBackgroundDrawable(dw);    this.setAnimationStyle(R.style.pop_anim);  }  public GridView getGridView(){    return gvSelectNum;  }  public void setTotalDoneNum(String num){    if (tvTotaDoneNums!=null){}    tvTotaDoneNums.setText(num);  }

}

0 0