List of usage examples for android.app Dialog setOnKeyListener
public void setOnKeyListener(@Nullable OnKeyListener onKeyListener)
From source file:org.catrobat.catroid.ui.dialogs.TextDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_text_dialog, null); input = (EditText) dialogView.findViewById(R.id.dialog_text_edit_text); inputTitle = (TextView) dialogView.findViewById(R.id.dialog_text_text_view); if (getHint() != null) { input.setHint(getHint());//from ww w . ja va 2 s . co m } input.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { getDialog().getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); initialize(); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView).setTitle(getTitle()) .setNegativeButton(R.string.cancel_button, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create(); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { boolean okButtonResult = handleOkButton(); onOkButtonHandled(); if (okButtonResult) { dismiss(); } return okButtonResult; } return false; } }); dialog.setCanceledOnTouchOutside(true); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button buttonPositive = ((AlertDialog) getDialog()).getButton(DialogInterface.BUTTON_POSITIVE); buttonPositive.setEnabled(getPositiveButtonEnabled()); setPositiveButtonClickCustomListener(); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT); initTextChangedListener(); } }); return dialog; }
From source file:hku.fyp14017.blencode.ui.dialogs.TextDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()) .inflate(hku.fyp14017.blencode.R.layout.dialog_text_dialog, null); input = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_text_edit_text); inputTitle = (TextView) dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_text_text_view); if (getHint() != null) { input.setHint(getHint());// ww w. j a v a2s . co m } input.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { getDialog().getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); initialize(); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView).setTitle(getTitle()) .setNegativeButton(hku.fyp14017.blencode.R.string.cancel_button, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }).setPositiveButton(hku.fyp14017.blencode.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).create(); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { boolean okButtonResult = handleOkButton(); onOkButtonHandled(); if (okButtonResult) { dismiss(); } return okButtonResult; } return false; } }); dialog.setCanceledOnTouchOutside(true); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button buttonPositive = ((AlertDialog) getDialog()).getButton(DialogInterface.BUTTON_POSITIVE); buttonPositive.setEnabled(getPositiveButtonEnabled()); setPositiveButtonClickCustomListener(); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT); initTextChangedListener(); } }); return dialog; }
From source file:com.allwinner.theatreplayer.launcher.activity.LaunchActivity.java
public void openDialog() { // Dialog dialog = null; // Builder builder = new Dialog.Builder(this).setTitle("?").setMessage("??"); // dialog = builder.create(); // dialog.show(); Dialog dialog = new Dialog(this, R.style.CustomDialog); dialog.setContentView(R.layout.launcher_fail); dialog.setOnKeyListener(keylistener); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false);// w ww . j a va 2 s. c o m dialog.show(); }
From source file:com.nbplus.vbroadlauncher.fragment.LoadIoTDevicesDialogFragmentStatus.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = new Dialog( getActivity()/*new ContextThemeWrapper(getActivity(), R.style.FullScreenDialog)*/); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); setRetainInstance(true);/*from www . j ava 2s.c o m*/ originalOrientation = getActivity().getRequestedOrientation(); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // fullscreen without statusbar dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); dialog.setCancelable(false); this.setCancelable(false); // disable back key dialog.setOnKeyListener(this); // set content view View v = getActivity().getLayoutInflater().inflate(R.layout.fragment_iot_devices, null, false); dialog.setContentView(v); // grid view mGridView = (GridView) v.findViewById(R.id.iot_devices_grid); mGridView.setEmptyView(v.findViewById(android.R.id.empty)); // set button control mCloseButton = (ImageButton) v.findViewById(R.id.btn_close); mCloseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "onClick btnClose.."); ((BaseActivity) getActivity()).dismissProgressDialog(); Intent sendIntent = new Intent(); sendIntent.setAction(Constants.ACTION_IOT_DEVICE_LIST); sendIntent.putExtra(Constants.EXTRA_IOT_DEVICE_CANCELED, true); LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(sendIntent); dismiss(); } }); mRefreshButton = (Button) v.findViewById(R.id.btn_refresh); mRefreshButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "onClick btnRefresh.."); ((BaseActivity) getActivity()).showProgressDialog(); IoTInterface.getInstance().getDevicesList(DeviceTypes.ALL, LoadIoTDevicesDialogFragmentStatus.this, true); mHandler.postDelayed(new Runnable() { @Override public void run() { ((BaseActivity) getActivity()).dismissProgressDialog(); } }, 6000); } }); mSendButton = (Button) v.findViewById(R.id.btn_send); mSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "onClick btnSend.."); ((BaseActivity) getActivity()).dismissProgressDialog(); showSyncAlertDialog(); } }); mGridView.setOnItemClickListener(this); return dialog; }
From source file:org.catrobat.catroid.ui.dialogs.OverwriteRenameDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_overwrite_project, null); replaceButton = (RadioButton) dialogView.findViewById(R.id.dialog_overwrite_project_radio_replace); replaceButton.setOnClickListener(this); renameButton = (RadioButton) dialogView.findViewById(R.id.dialog_overwrite_project_radio_rename); renameButton.setOnClickListener(this); projectText = (EditText) dialogView.findViewById(R.id.dialog_overwrite_project_edit); projectText.setText(programName);// w ww . j a v a 2s. c om projectTextView = (TextView) dialogView.findViewById(R.id.dialog_overwrite_project_edit_text); projectTextLine = dialogView.findViewById(R.id.dialog_overwrite_project_edit_line); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView).setTitle(R.string.overwrite_text) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ToastUtil.showError(context, R.string.notification_download_project_cancel); } }).create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { handleOkButton(); } }); } }); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { boolean okButtonResult = handleOkButton(); if (okButtonResult) { dismiss(); } return okButtonResult; } else if (keyCode == KeyEvent.KEYCODE_BACK) { ToastUtil.showError(context, R.string.notification_download_project_cancel); return true; } return false; } }); return dialog; }
From source file:org.catrobat.catroid.ui.dialogs.OverwriteRenameMediaDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_overwrite_media, null); replaceButton = (RadioButton) dialogView.findViewById(R.id.dialog_overwrite_media_radio_replace); replaceButton.setOnClickListener(this); renameButton = (RadioButton) dialogView.findViewById(R.id.dialog_overwrite_media_radio_rename); renameButton.setOnClickListener(this); mediaText = (EditText) dialogView.findViewById(R.id.dialog_overwrite_media_edit); mediaText.setText(mediaName);/*from ww w .j ava2 s .c om*/ mediaTextView = (TextView) dialogView.findViewById(R.id.dialog_overwrite_media_edit_text); mediaTextLine = dialogView.findViewById(R.id.dialog_overwrite_media_edit_line); final int header; final int replaceText; final int renameText; final int renameHeaderText; switch (mediaType) { case Constants.MEDIA_TYPE_LOOK: header = R.string.look_rename_overwrite; replaceText = R.string.overwrite_replace_look; renameText = R.string.overwrite_rename_look; renameHeaderText = R.string.new_look_name; break; case Constants.MEDIA_TYPE_SOUND: header = R.string.rename_sound_overwrite; replaceText = R.string.overwrite_replace_sound; renameText = R.string.overwrite_rename_sound; renameHeaderText = R.string.new_sound_name; break; default: header = R.string.rename_sprite_dialog; replaceText = R.string.overwrite_replace_default; renameText = R.string.overwrite_rename_default; renameHeaderText = R.string.new_sound_name; } replaceButton.setText(replaceText); renameButton.setText(renameText); mediaTextView.setText(renameHeaderText); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView).setTitle(header) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }).create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(final DialogInterface dialog) { Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { handleOkButton(); } }); } }); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { boolean okButtonResult = handleOkButton(); if (!okButtonResult) { return false; } else { dismiss(); } return okButtonResult; } else if (keyCode == KeyEvent.KEYCODE_BACK) { dismiss(); return true; } return false; } }); return dialog; }
From source file:hku.fyp14017.blencode.ui.dialogs.OverwriteRenameDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(context) .inflate(hku.fyp14017.blencode.R.layout.dialog_overwrite_project, null); replaceButton = (RadioButton) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_radio_replace); replaceButton.setOnClickListener(this); renameButton = (RadioButton) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_radio_rename); renameButton.setOnClickListener(this); projectText = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_edit); projectText.setText(programName);/*w ww . j ava 2 s . c o m*/ projectTextView = (TextView) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_edit_text); projectTextLine = dialogView.findViewById(hku.fyp14017.blencode.R.id.dialog_overwrite_project_edit_line); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(hku.fyp14017.blencode.R.string.overwrite_text) .setPositiveButton(hku.fyp14017.blencode.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setNegativeButton(hku.fyp14017.blencode.R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(context, hku.fyp14017.blencode.R.string.notification_download_project_cancel, Toast.LENGTH_SHORT).show(); } }) .create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); positiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { handleOkButton(); } }); } }); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { boolean okButtonResult = handleOkButton(); if (okButtonResult) { dismiss(); } return okButtonResult; } else if (keyCode == KeyEvent.KEYCODE_BACK) { Toast.makeText(context, hku.fyp14017.blencode.R.string.notification_download_project_cancel, Toast.LENGTH_SHORT).show(); return true; } return false; } }); return dialog; }
From source file:org.wso2.cdm.agent.AuthenticationActivity.java
public void showAgreement(String message, String title) { final Dialog dialog = new Dialog(context); dialog.setContentView(R.layout.custom_terms_popup); dialog.setTitle(CommonUtilities.EULA_TITLE); dialog.setCancelable(false);/*from w w w . j av a 2 s .c om*/ WebView web = (WebView) dialog.findViewById(R.id.webview); String html = "<html><body>" + message + "</body></html>"; String mime = "text/html"; String encoding = "utf-8"; web.loadDataWithBaseURL(null, html, mime, encoding, null); Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK); Button cancelButton = (Button) dialog.findViewById(R.id.dialogButtonCancel); dialogButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Preference.put(context, getResources().getString(R.string.shared_pref_isagreed), "1"); dialog.dismiss(); loadPincodeAcitvity(); } }); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); cancelEntry(); } }); dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) { return true; } else if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { return true; } return false; } }); dialog.show(); }
From source file:group.pals.android.lib.ui.filechooser.utils.ui.history.HistoryFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (BuildConfig.DEBUG) Log.d(_ClassName, "onCreateDialog()"); Dialog dialog = new Dialog(getActivity(), R.style.Afc_Theme_Dialog_Dark) { @Override// w w w. ja v a 2 s. c o m public boolean onCreateOptionsMenu(Menu menu) { getActivity().getMenuInflater().inflate(R.menu.afc_viewgroup_history, menu); return super.onCreateOptionsMenu(menu); }// onCreateOptionsMenu() @Override public boolean onPrepareOptionsMenu(Menu menu) { menu.findItem(R.id.afc_menuitem_clear) .setEnabled(mHistoryCursorAdapter != null && mHistoryCursorAdapter.getGroupCount() > 0); return true; }// onPrepareOptionsMenu() @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { if (BuildConfig.DEBUG) Log.d(_ClassName, "onMenuItemSelected() in Dialog"); Ui.showSoftKeyboard(mSearchView, false); if (item.getItemId() == R.id.afc_menuitem_clear) doConfirmClearHistory(); return true; }// onMenuItemSelected() }; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(initContentView(dialog.getLayoutInflater(), null)); dialog.setOnKeyListener(mDialogOnKeyListener); Ui.adjustDialogSizeForLargeScreen(dialog); return dialog; }
From source file:com.haibison.android.anhuu.utils.ui.history.HistoryFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (BuildConfig.DEBUG) Log.d(CLASSNAME, "onCreateDialog()"); Dialog dialog = new Dialog(getActivity(), UI.resolveAttribute(getActivity(), R.attr.anhuu_f5be488d_theme_dialog)) { @Override//from w w w . j a v a2 s . c om public boolean onCreateOptionsMenu(Menu menu) { getActivity().getMenuInflater().inflate(R.menu.anhuu_f5be488d_viewgroup_history, menu); return super.onCreateOptionsMenu(menu); }// onCreateOptionsMenu() @Override public boolean onPrepareOptionsMenu(Menu menu) { menu.findItem(R.id.anhuu_f5be488d_menuitem_clear) .setEnabled(mHistoryCursorAdapter != null && mHistoryCursorAdapter.getGroupCount() > 0); return true; }// onPrepareOptionsMenu() @Override public boolean onMenuItemSelected(int featureId, MenuItem item) { if (BuildConfig.DEBUG) Log.d(CLASSNAME, "onMenuItemSelected() in Dialog"); UI.showSoftKeyboard(mSearchView, false); if (item.getItemId() == R.id.anhuu_f5be488d_menuitem_clear) doConfirmClearHistory(); return true; }// onMenuItemSelected() }; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(true); dialog.setContentView(initContentView(dialog.getLayoutInflater(), null)); dialog.setOnKeyListener(mDialogOnKeyListener); UI.adjustDialogSizeForLargeScreens(dialog); return dialog; }