List of usage examples for android.app ProgressDialog setOnKeyListener
public void setOnKeyListener(@Nullable OnKeyListener onKeyListener)
From source file:Main.java
public static ProgressDialog showProgressDialog(Context context) { ProgressDialog myProgressDialog = new ProgressDialog(context); myProgressDialog.setMessage("Please wait..."); myProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); myProgressDialog.show();//from w w w . j av a2 s . c o m myProgressDialog.setCancelable(false); myProgressDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) { return true; } return false; } }); return myProgressDialog; }
From source file:Main.java
public static ProgressDialog createProgressDialog(final Activity activity, int progressDialogTitleId, int progressDialogMsgId) { ProgressDialog progressDialog = new ProgressDialog(activity); if (progressDialogTitleId > 0) { progressDialog.setTitle(progressDialogTitleId); } else {/*w ww . jav a2 s. co m*/ progressDialog.setTitle(activity.getResources().getIdentifier(PROGRESS_DIALOG_TITLE_RESOURCE, "string", activity.getPackageName())); } if (progressDialogMsgId > 0) { progressDialog.setMessage(activity.getString(progressDialogMsgId)); } else { progressDialogMsgId = activity.getResources().getIdentifier(PROGRESS_DIALOG_MESSAGE_RESOURCE, "string", activity.getPackageName()); progressDialog.setMessage(activity.getString(progressDialogMsgId)); } progressDialog.setIndeterminate(true); progressDialog.setOnKeyListener(new OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { activity.onKeyDown(keyCode, event); return false; } }); // progressDialog.setInverseBackgroundForced(true); return progressDialog; }
From source file:com.google.android.apps.tvremote.PairingActivity.java
private ProgressDialog buildProgressDialog() { ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(getString(R.string.pairing_waiting)); dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialogInterface, int which, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { cancelPairing();//from w w w. ja v a2 s .c o m return true; } return false; } }); dialog.setButton(getString(R.string.pairing_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int which) { cancelPairing(); } }); return dialog; }
From source file:com.nbplus.progress.ProgressDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final ProgressDialog dialog = new ProgressDialog(getActivity()); dialog.setCancelable(false);//from w w w . j a v a 2s.co m this.setCancelable(false); // Disable the back button DialogInterface.OnKeyListener keyListener = new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { return true; } return false; } }; dialog.setOnKeyListener(keyListener); return dialog; }
From source file:org.cvasilak.jboss.mobile.app.fragments.dialogs.ProgressDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { ProgressDialog dialog = new ProgressDialog(getActivity()); dialog.setMessage(getActivity().getString(getArguments().getInt("message"))); dialog.setIndeterminate(true);//from ww w . j a va 2 s .c om dialog.setCancelable(false); // Disable the back button DialogInterface.OnKeyListener keyListener = new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { return (keyCode == KeyEvent.KEYCODE_BACK); } }; dialog.setOnKeyListener(keyListener); return dialog; }
From source file:org.totschnig.myexpenses.dialog.ProgressDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final ProgressDialog dialog = new ProgressDialog(getActivity()); dialog.setMessage(getString(getArguments().getInt("message"))); dialog.setIndeterminate(true);//from w ww . j a va2s .c o m dialog.setCancelable(false); // Disable the back button OnKeyListener keyListener = new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { return true; } return false; } }; dialog.setOnKeyListener(keyListener); return dialog; }
From source file:org.totschnig.myexpenses.dialog.ProgressDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final ProgressDialog dialog = new ProgressDialog(getActivity()); int message = getArguments().getInt("message"); if (message != 0) dialog.setMessage(getString(message)); else/* w w w . j ava 2 s .c om*/ dialog.setMessage(""); dialog.setIndeterminate(true); dialog.setCancelable(false); // Disable the back button OnKeyListener keyListener = new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { return true; } return false; } }; dialog.setOnKeyListener(keyListener); return dialog; }
From source file:com.entertailion.android.dial.ServerFinder.java
private ProgressDialog buildProgressDialog(String message, DialogInterface.OnClickListener cancelListener) { ProgressDialog dialog = new ProgressDialog(this); dialog.setMessage(message);//from w ww . j a v a 2s . c o m dialog.setOnKeyListener(new DialogInterface.OnKeyListener() { public boolean onKey(DialogInterface dialogInterface, int which, KeyEvent event) { if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) { finish(); return true; } return false; } }); dialog.setButton(getString(R.string.finder_cancel), cancelListener); return dialog; }
From source file:id.nci.stm_9.ProgressDialogFragment.java
/** * Creates dialog//w w w. j a v a2s . co m */ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Activity activity = getActivity(); ProgressDialog dialog = new ProgressDialog(activity); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(false); int messageId = getArguments().getInt(ARG_MESSAGE_ID); int style = getArguments().getInt(ARG_STYLE); dialog.setMessage(getString(messageId)); dialog.setProgressStyle(style); // Disable the back button OnKeyListener keyListener = new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { return true; } return false; } }; dialog.setOnKeyListener(keyListener); return dialog; }
From source file:me.panpf.tool4a.app.ProgressDialogFragment.java
/** * ?/*from www .ja v a 2 s . c o m*/ * * @param progressDialog ? */ private void applyParams(ProgressDialog progressDialog) { if (builder == null) throw new IllegalArgumentException("builder null ?setBuilder()Builder"); progressDialog.setTitle(builder.title); progressDialog.setMessage(builder.message != null ? builder.message : (Locale.CHINA.equals(Locale.getDefault()) ? MESSAGE_DEFAULT_CHINA : MESSAGE_DEFAULT_OTHER)); if (builder.confirmButtonName != null) { progressDialog.setButton(AlertDialog.BUTTON_POSITIVE, builder.confirmButtonName, builder.confirmButtonClickListener); } if (builder.cancelButtonName != null) { progressDialog.setButton(AlertDialog.BUTTON_NEGATIVE, builder.cancelButtonName, builder.cancelButtonClickListener); } if (builder.neutralButtonName != null) { progressDialog.setButton(AlertDialog.BUTTON_NEUTRAL, builder.neutralButtonName, builder.neutralButtonClickListener); } progressDialog.setOnKeyListener(builder.onKeyListener); progressDialog.setOnShowListener(builder.onShowListener); setCancelable(builder.cancelable); }