当前位置: 首页>>代码示例>>Java>>正文


Java Dialog.setOnKeyListener方法代码示例

本文整理汇总了Java中android.app.Dialog.setOnKeyListener方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.setOnKeyListener方法的具体用法?Java Dialog.setOnKeyListener怎么用?Java Dialog.setOnKeyListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Dialog的用法示例。


在下文中一共展示了Dialog.setOnKeyListener方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initDialog

import android.app.Dialog; //导入方法依赖的package包/类
private void initDialog() {
    contentLayout = new FrameLayout(activity);
    contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
    contentLayout.setFocusable(true);
    contentLayout.setFocusableInTouchMode(true);
    //contentLayout.setFitsSystemWindows(true);
    dialog = new Dialog(activity);
    dialog.setCanceledOnTouchOutside(false);//触摸屏幕取消窗体
    dialog.setCancelable(false);//按返回键取消窗体
    dialog.setOnKeyListener(this);
    dialog.setOnDismissListener(this);
    Window window = dialog.getWindow();
    if (window != null) {
        window.setGravity(Gravity.BOTTOM);
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        //AndroidRuntimeException: requestFeature() must be called before adding content
        window.requestFeature(Window.FEATURE_NO_TITLE);
        window.setContentView(contentLayout);
    }
    setSize(screenWidthPixels, WRAP_CONTENT);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:BaseDialog.java

示例2: initDialog

import android.app.Dialog; //导入方法依赖的package包/类
private void initDialog() {
    contentLayout = new FrameLayout(activity);
    contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
    contentLayout.setFocusable(true);
    contentLayout.setFocusableInTouchMode(true);
    dialog = new Dialog(activity);
    dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
    dialog.setCancelable(true);//按返回键取消窗体
    dialog.setOnKeyListener(this);
    dialog.setOnDismissListener(this);
    Window window = dialog.getWindow();
    if (window != null) {
        window.setGravity(Gravity.BOTTOM);
        window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        //AndroidRuntimeException: requestFeature() must be called before adding content
        window.requestFeature(Window.FEATURE_NO_TITLE);
        window.setContentView(contentLayout);
    }
    setSize(screenWidthPixels, WRAP_CONTENT);
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:21,代码来源:BasicPopup.java

示例3: onCreateDialog

import android.app.Dialog; //导入方法依赖的package包/类
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.setOnShowListener(dialogInterface -> {
        if (ViewHelper.isTablet(getActivity())) {
            if (dialog.getWindow() != null) {
                dialog.getWindow().setLayout(
                        ViewGroup.LayoutParams.WRAP_CONTENT,
                        ViewGroup.LayoutParams.MATCH_PARENT);
            }
        }
        onDialogIsShowing();
    });
    dialog.setOnKeyListener((dialog1, keyCode, event) -> {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            isAlreadyHidden = true;
            onDismissedByScrolling();
        }
        return false;
    });
    return dialog;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:22,代码来源:BaseBottomSheetDialog.java

示例4: a

import android.app.Dialog; //导入方法依赖的package包/类
public static Dialog a(Context context, String str, String str2, String str3, OnClickListener onClickListener, String str4, OnClickListener onClickListener2) {
    Builder builder = new Builder(context);
    if (a) {
        if (!(TextUtils.isEmpty(str4) || onClickListener2 == null)) {
            builder.setPositiveButton(str4, onClickListener2);
        }
        if (!(TextUtils.isEmpty(str3) || onClickListener == null)) {
            builder.setNegativeButton(str3, onClickListener);
        }
    } else {
        if (!(TextUtils.isEmpty(str3) || onClickListener == null)) {
            builder.setPositiveButton(str3, onClickListener);
        }
        if (!(TextUtils.isEmpty(str4) || onClickListener2 == null)) {
            builder.setNegativeButton(str4, onClickListener2);
        }
    }
    builder.setTitle(str);
    builder.setMessage(str2);
    Dialog create = builder.create();
    create.setCanceledOnTouchOutside(false);
    create.setOnKeyListener(new e());
    try {
        create.show();
    } catch (Throwable th) {
    }
    return create;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:29,代码来源:d.java

示例5: CommonAlertDialog

import android.app.Dialog; //导入方法依赖的package包/类
public CommonAlertDialog(Context context, Builder builder) {

        this.mBuilder = builder;
        mDialog = new Dialog(context, R.style.CommonAlertDialogStyle);
        mDialogView = View.inflate(context, R.layout.common_widget_dialog_prepare, null);
        mTitle = (TextView) mDialogView.findViewById(R.id.dialog_normal_title);
        mContent = (TextView) mDialogView.findViewById(R.id.dialog_normal_content);
        mLeftBtn = (Button) mDialogView.findViewById(R.id.dialog_normal_leftbtn);
        mRightBtn = (Button) mDialogView.findViewById(R.id.dialog_normal_rightbtn);
        mSingleBtn = (Button) mDialogView.findViewById(R.id.dialog_normal_midbtn);
        ll_space = (LinearLayout) mDialogView.findViewById(R.id.ll_space);
        mSecondContent = (TextView) mDialogView.findViewById(R.id.dialog_normal_secondcontent);
        mDialog.setContentView(mDialogView);

        mDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                return true;
            }
        });

        Window dialogWindow = mDialog.getWindow();
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        lp.width = dip2px(context.getApplicationContext(), 280f);
        lp.gravity = Gravity.CENTER;
        dialogWindow.setAttributes(lp);

        initDialog(builder);
    }
 
开发者ID:sunshinecoast,项目名称:ScreenRecordCaptureMaster,代码行数:31,代码来源:CommonAlertDialog.java

示例6: doCaptureKey

import android.app.Dialog; //导入方法依赖的package包/类
public Dialog doCaptureKey(){
	
	final Dialog d = new Dialog(_gamePadActivity);
	d.setContentView(R.layout.prefs_capture_key);
	d.setCanceledOnTouchOutside(true);
	d.setOnKeyListener(new Dialog.OnKeyListener() {
           @Override
           public boolean onKey(DialogInterface arg0, int keyCode,
                   KeyEvent event) {
           	_setActionKey(keyCode);
           	d.dismiss();
               return true;
           }
       });
	
	Button b = (Button)d.findViewById(R.id.buttonResetToDefault);
	b.setOnClickListener(new Button.OnClickListener(){
		@Override
		public void onClick(View v) {
			switch(_captureKey){
			case PICK_UP: _setActionKey(KeyEvent.KEYCODE_BUTTON_Y); break;
			case JUMP: _setActionKey(KeyEvent.KEYCODE_BUTTON_A); break;
			case PUNCH: _setActionKey(KeyEvent.KEYCODE_BUTTON_X); break;
			case BOMB: _setActionKey(KeyEvent.KEYCODE_BUTTON_B); break;
			case RUN1: _setActionKey(KeyEvent.KEYCODE_BUTTON_L1); break;
			case RUN2: _setActionKey(KeyEvent.KEYCODE_BUTTON_R1); break;
			case START: _setActionKey(KeyEvent.KEYCODE_BUTTON_START); break;
			default:
				LogThread.log("Error: unrecognized key in doActionKey",null);
				break;
			}
			d.dismiss();
		}});

	d.setTitle(R.string.capturing);
	d.show();
	return d;
}
 
开发者ID:efroemling,项目名称:bombsquad-remote-android,代码行数:39,代码来源:GamePadActivity.java

示例7: startFullScreen

import android.app.Dialog; //导入方法依赖的package包/类
public void startFullScreen(final Context context) {

        isToggleFullScreen = true;

        currentVideoPlayer.setBackButtonVisibility(View.VISIBLE);
        Activity activity = ListVideoUtils.getActivity(context);

        removePlayerFromParent();
        int screenWidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        int screenHeight = activity.getWindowManager().getDefaultDisplay().getHeight();
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(screenHeight, screenWidth);
        currentVideoPlayer.setLayoutParams(layoutParams);

        fullVideoDialog = new Dialog(activity, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
        fullVideoDialog.setContentView(VideoPlayerManager.getInstance().getCurrentVideoPlayer());
        fullVideoDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    handleFullScreen(context);
                }
                return false;
            }
        });
        fullVideoDialog.show();
        toggledFullscreen(activity, true);
    }
 
开发者ID:qq1210514049,项目名称:ListVideoPlayer,代码行数:28,代码来源:VideoPlayerManager.java


注:本文中的android.app.Dialog.setOnKeyListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。