本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}