zoukankan      html  css  js  c++  java
  • android dialog弹出的情况下监听返回键

    view = LayoutInflater.from(getActivity()).inflate(
    R.layout.dialog_tips, null);
      title2 = (TextView) view.findViewById(R.id.title2);

      dialog = new Dialog(getActivity());
    dialog.setOnKeyListener(new OnKeyListener() {

    @Override
    public boolean onKey(DialogInterface dialog,
    int keyCode, KeyEvent event) {
      if (keyCode == KeyEvent.KEYCODE_BACK
        && event.getRepeatCount() == 0) {
        getActivity().finish();
      }
        return false;
      }
      });
      dialog.getWindow().setBackgroundDrawable(
      new ColorDrawable(
      android.R.color.transparent));
      dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(view);
    dialog.getWindow()
    .setLayout(
    ScreenUtil
    .getScreenWidth(getActivity()) - 50,
    DensityUtil.dp2px(400));
    dialog.show();

  • 相关阅读:
    java web
    java web
    java
    周末总结7
    java
    java
    java
    java
    java web
    java
  • 原文地址:https://www.cnblogs.com/zhaoleigege/p/4971045.html
Copyright © 2011-2022 走看看