List of usage examples for android.app Dialog getWindow
public @Nullable Window getWindow()
From source file:eu.power_switch.gui.dialog.ConfigurationDialog.java
@NonNull @Override// w w w .j a v a2s. c o m public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = new Dialog(getActivity()) { @Override public void onBackPressed() { if (modified) { // ask to really close new AlertDialog.Builder(getActivity()).setTitle(R.string.are_you_sure) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { getDialog().cancel(); } }).setNeutralButton(android.R.string.no, null) .setMessage(R.string.all_changes_will_be_lost).show(); } else { getDialog().cancel(); } } }; dialog.setTitle(getDialogTitle()); dialog.setCanceledOnTouchOutside(isCancelableOnTouchOutside()); dialog.getWindow().setSoftInputMode(getSoftInputMode()); dialog.show(); return dialog; }
From source file:hku.fyp14017.blencode.ui.dialogs.UploadProjectDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View dialogView = LayoutInflater.from(getActivity()) .inflate(hku.fyp14017.blencode.R.layout.dialog_upload_project, null); projectRename = (TextView) dialogView.findViewById(hku.fyp14017.blencode.R.id.tv_project_rename); projectDescriptionField = (EditText) dialogView .findViewById(hku.fyp14017.blencode.R.id.project_description_upload); projectUploadName = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.project_upload_name); sizeOfProject = (TextView) dialogView .findViewById(hku.fyp14017.blencode.R.id.dialog_upload_size_of_project); Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView) .setTitle(hku.fyp14017.blencode.R.string.upload_project_dialog_title) .setPositiveButton(hku.fyp14017.blencode.R.string.upload_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleUploadButtonClick(); }/* w w w. ja v a2s . co m*/ }) .setNegativeButton(hku.fyp14017.blencode.R.string.cancel_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handleCancelButtonClick(); } }) .create(); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); dialog.setOnShowListener(new OnShowListener() { @Override public void onShow(DialogInterface dialog) { initListeners(); InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(projectUploadName, InputMethodManager.SHOW_IMPLICIT); } }); initControls(); return dialog; }
From source file:android.support.v7.app.WindowDecorActionBar.java
public WindowDecorActionBar(Dialog dialog) { mDialog = dialog; init(dialog.getWindow().getDecorView()); }
From source file:com.ivalentin.margolariak.SettingsLayout.java
private void showDialog(String title, String text) { //Create the dialog final Dialog dialog = new Dialog(getActivity()); //Set up dialog window dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_settings); //Set the custom dialog components - text, image and button TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_dialog_settings_title); WebView wvText = (WebView) dialog.findViewById(R.id.wv_dialog_settings_text); if (Build.VERSION.SDK_INT >= 19) { wvText.setLayerType(View.LAYER_TYPE_HARDWARE, null); } else {//from w ww . jav a 2s.co m wvText.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } Button btClose = (Button) dialog.findViewById(R.id.bt_dialog_settings_close); //Set text tvTitle.setText(title); wvText.loadDataWithBaseURL(null, text, "text/html", "utf-8", null); //Set close button btClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); //Set parameters WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; lp.gravity = Gravity.CENTER; lp.dimAmount = 0.4f; dialog.getWindow().setAttributes(lp); //Show dialog dialog.show(); }
From source file:com.birdeye.MainActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!Prefs.usernames.isSet()) { Prefs.usernames.set(Twitter.getSessionManager().getActiveSession().getUserName()); }/* w w w . j a va 2s. c o m*/ setContentView(R.layout.main); ButterKnife.bind(this); // hideSystemUI(this); Chartboost.startWithAppId(MainActivity.this, "57552756f6cd4526e365b9d1", "239b2e3aa657ccdcdf0b9674c8750f077b5e0aed"); Chartboost.setLoggingLevel(CBLogging.Level.ALL); Chartboost.setDelegate(delegate); Chartboost.onCreate(this); tv_cancel = (TextView) findViewById(R.id.tv_cancel); tvSetTimer = (Button) findViewById(R.id.tvSetTimer); if (!BillingProcessor.isIabServiceAvailable(MainActivity.this)) { // showToast("In-app billing service is unavailable, please upgrade Android Market/Play to version >= 3.9.16"); onBackPressed(); } bp = new BillingProcessor(this, LICENSE_KEY, MERCHANT_ID, new BillingProcessor.IBillingHandler() { @Override public void onProductPurchased(String productId, TransactionDetails details) { showToast("onProductPurchased: " + productId); // updateTextViews(); } @Override public void onBillingError(int errorCode, Throwable error) { showToast("onBillingError: " + Integer.toString(errorCode)); } @Override public void onBillingInitialized() { showToast("onBillingInitialized"); readyToPurchase = true; //updateTextViews(); } @Override public void onPurchaseHistoryRestored() { showToast("onPurchaseHistoryRestored"); for (String sku : bp.listOwnedProducts()) Log.d(LOG_TAG, "Owned Managed Product: " + sku); for (String sku : bp.listOwnedSubscriptions()) Log.d(LOG_TAG, "Owned Subscription: " + sku); //updateTextViews(); Log.i(LOG_TAG, String.format("%s is%s subscribed", SUBSCRIPTION_ID, bp.isSubscribed(SUBSCRIPTION_ID) ? "" : " not")); } }); subs = bp.getSubscriptionListingDetails(SUBSCRIPTION_ID); // showToast(subs != null ? subs.toString() : "Failed to load subscription details"); if (subs == null) { // showToast(subs != null ? subs.toString() : "Failed to load subscription details"); Globals.hasPaid = false; } else { Globals.hasPaid = true; } if (Globals.hasPaid) { tvSetTimer.setVisibility(View.VISIBLE); message4.setVisibility(View.VISIBLE); message5.setVisibility(View.VISIBLE); message6.setVisibility(View.VISIBLE); message7.setVisibility(View.VISIBLE); message8.setVisibility(View.VISIBLE); message9.setVisibility(View.VISIBLE); message10.setVisibility(View.VISIBLE); message11.setVisibility(View.VISIBLE); message12.setVisibility(View.VISIBLE); message13.setVisibility(View.VISIBLE); message14.setVisibility(View.VISIBLE); message15.setVisibility(View.VISIBLE); message16.setVisibility(View.VISIBLE); message17.setVisibility(View.VISIBLE); message18.setVisibility(View.VISIBLE); message19.setVisibility(View.VISIBLE); message20.setVisibility(View.VISIBLE); message21.setVisibility(View.VISIBLE); message22.setVisibility(View.VISIBLE); message23.setVisibility(View.VISIBLE); message24.setVisibility(View.VISIBLE); message25.setVisibility(View.VISIBLE); ets = Arrays.asList(usernames, hashtags, message1, message2, message3, message4, message5, message6, message7, message8, message9, message10, message11, message12, message13, message14, message15, message16, message17, message18, message19, message20, message21, message22, message23, message24, message25); } else { tvSetTimer.setVisibility(View.GONE); message4.setVisibility(View.GONE); message5.setVisibility(View.GONE); message6.setVisibility(View.GONE); message7.setVisibility(View.GONE); message8.setVisibility(View.GONE); message9.setVisibility(View.GONE); message10.setVisibility(View.GONE); message11.setVisibility(View.GONE); message12.setVisibility(View.GONE); message13.setVisibility(View.GONE); message14.setVisibility(View.GONE); message15.setVisibility(View.GONE); message16.setVisibility(View.GONE); message17.setVisibility(View.GONE); message18.setVisibility(View.GONE); message19.setVisibility(View.GONE); message20.setVisibility(View.GONE); message21.setVisibility(View.GONE); message22.setVisibility(View.GONE); message23.setVisibility(View.GONE); message24.setVisibility(View.GONE); message25.setVisibility(View.GONE); ets = Arrays.asList(usernames, hashtags, message1, message2, message3); } tvSetTimer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(MainActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setContentView(R.layout.input_time); dialog.setCancelable(true); Button bt_set = (Button) dialog.findViewById(R.id.bt_set); final EditText et_time = (EditText) dialog.findViewById(R.id.et_time); bt_set.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (et_time.getText().toString().equalsIgnoreCase("")) { Toast.makeText(MainActivity.this, "Please enter time to auto shut down", Toast.LENGTH_SHORT).show(); } else { int valueTimer = Integer.parseInt(et_time.getText().toString()) * 1000; initateCounter(valueTimer); tv_cancel.setText("Auto ShutDown started"); tvSetTimer.setVisibility(View.GONE); tv_cancel.setVisibility(View.VISIBLE); dialog.dismiss(); } } }); dialog.show(); } }); cameras.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, Facing.values())); //noinspection ConstantConditions cameras.setSelection(Prefs.facing.get().ordinal()); cameras.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Prefs.facing.set(Facing.values()[position]); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); for (TextInputEditText et : ets) { DrawableCompat.setTint(et.getBackground(), ContextCompat.getColor(this, R.color.colorAccent)); final TextInputLayout til = textLayout(et); til.setError(null); til.setErrorEnabled(false); } TextViews.setText(usernames, Prefs.usernames.get()); TextViews.setText(hashtags, Prefs.hashtags.get()); TextViews.setText(message1, Prefs.message1.get()); TextViews.setText(message2, Prefs.message2.get()); TextViews.setText(message3, Prefs.message3.get()); TextViews.setText(message4, Prefs.message4.get()); TextViews.setText(message5, Prefs.message5.get()); TextViews.setText(message6, Prefs.message6.get()); TextViews.setText(message7, Prefs.message7.get()); TextViews.setText(message8, Prefs.message8.get()); TextViews.setText(message9, Prefs.message9.get()); TextViews.setText(message10, Prefs.message10.get()); TextViews.setText(message11, Prefs.message11.get()); TextViews.setText(message12, Prefs.message12.get()); TextViews.setText(message13, Prefs.message13.get()); TextViews.setText(message14, Prefs.message14.get()); TextViews.setText(message15, Prefs.message15.get()); TextViews.setText(message16, Prefs.message16.get()); TextViews.setText(message17, Prefs.message17.get()); TextViews.setText(message18, Prefs.message18.get()); TextViews.setText(message19, Prefs.message19.get()); TextViews.setText(message20, Prefs.message20.get()); TextViews.setText(message21, Prefs.message21.get()); TextViews.setText(message22, Prefs.message22.get()); TextViews.setText(message23, Prefs.message23.get()); TextViews.setText(message24, Prefs.message24.get()); TextViews.setText(message25, Prefs.message25.get()); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); getWindow().setBackgroundDrawableResource(R.color.bg); mAdView = (AdView) findViewById(R.id.adView); mInterstitialAd = new InterstitialAd(this); // set the ad unit ID mInterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen)); adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // Check the LogCat to get your test device ID .addTestDevice("EB02375D2DA62FFA0F6F145AD2302B3D").build(); // adRequest = new AdRequest.Builder().build(); mAdView.setAdListener(new AdListener() { @Override public void onAdLoaded() { } @Override public void onAdClosed() { // Toast.makeText(getApplicationContext(), "Ad is closed!", Toast.LENGTH_SHORT).show(); } @Override public void onAdFailedToLoad(int errorCode) { // Toast.makeText(getApplicationContext(), "Ad failed to load! error code: " + errorCode, Toast.LENGTH_SHORT).show(); } @Override public void onAdLeftApplication() { // Toast.makeText(getApplicationContext(), "Ad left application!", Toast.LENGTH_SHORT).show(); } @Override public void onAdOpened() { super.onAdOpened(); } }); mAdView.loadAd(adRequest); mInterstitialAd.loadAd(adRequest); mInterstitialAd.setAdListener(new AdListener() { public void onAdLoaded() { showInterstitial(); } @Override public void onAdClosed() { Toast.makeText(getApplicationContext(), "Ad is closed!", Toast.LENGTH_SHORT).show(); } @Override public void onAdFailedToLoad(int errorCode) { Toast.makeText(getApplicationContext(), "Ad failed to load! error code: " + errorCode, Toast.LENGTH_SHORT).show(); } @Override public void onAdLeftApplication() { Toast.makeText(getApplicationContext(), "Ad left application!", Toast.LENGTH_SHORT).show(); } @Override public void onAdOpened() { Toast.makeText(getApplicationContext(), "Ad is opened!", Toast.LENGTH_SHORT).show(); } }); if (Globals.hasPaid) { tv_cancel.setVisibility(View.GONE); mAdView.setVisibility(View.GONE); } else { // initateCounter(120000); startRepeatingTask(); mAdView.setVisibility(View.VISIBLE); } }
From source file:eu.power_switch.gui.dialog.ConfigurationDialogTabbed.java
@NonNull @Override//from www. j a va 2 s . c o m public Dialog onCreateDialog(Bundle savedInstanceState) { // ask to really close Dialog dialog = new Dialog(getActivity()) { @Override public void onBackPressed() { if (modified) { // ask to really close new AlertDialog.Builder(getActivity()).setTitle(R.string.are_you_sure) .setPositiveButton(android.R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { getDialog().cancel(); } }).setNeutralButton(android.R.string.no, null) .setMessage(R.string.all_changes_will_be_lost).show(); } else { getDialog().cancel(); } } }; dialog.setTitle(getDialogTitle()); dialog.setCanceledOnTouchOutside(isCancelableOnTouchOutside()); dialog.getWindow().setSoftInputMode(getSoftInputMode()); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; dialog.show(); dialog.getWindow().setAttributes(lp); dialog.show(); return dialog; }
From source file:com.emergencyskills.doe.aed.UI.activity.TabsActivity.java
void init() { // img=(ImageView)findViewById(R.id.logo); TextView build = (TextView) findViewById(R.id.checkfornew); build.setOnClickListener(new View.OnClickListener() { @Override// ww w .j ava2 s . c o m public void onClick(View v) { if (android.os.Build.VERSION.SDK_INT > 9) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); } CommonUtilities.logMe("about to check for version "); try { WebServiceHandler wsb = new WebServiceHandler(); ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>(); String result = wsb.getWebServiceData("http://doe.emergencyskills.com/api/version.php", postParameters); JSONObject jsonObject = new JSONObject(result); String version = jsonObject.getString("version"); String features = jsonObject.getString("features"); System.err.println("version is : " + version); if (!LoginActivity.myversion.equals(version)) { MyToast.popmessagelong( "There is a new build available. Please download for these features: " + features, TabsActivity.this); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://vireo.org/esiapp")); browserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(browserIntent); } else { MyToast.popmessagelong("You have the most current version!", TabsActivity.this); } } catch (Exception exc) { exc.printStackTrace(); } } }); TextView maillog = (TextView) findViewById(R.id.maillog); maillog.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(TabsActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_logout); TextView question = (TextView) dialog.findViewById(R.id.question); question.setText("Are you sure you want to email the log?"); TextView extra = (TextView) dialog.findViewById(R.id.extratext); extra.setText(""); dialog.getWindow().setBackgroundDrawable( new ColorDrawable(getResources().getColor(android.R.color.transparent))); Button yes = (Button) dialog.findViewById(R.id.yesbtn); yes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { "rachelc@gmail.com" }); i.putExtra(Intent.EXTRA_SUBJECT, "Sending Log"); i.putExtra(Intent.EXTRA_TEXT, "body of email"); try { startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(TabsActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } finish(); } }); Button no = (Button) dialog.findViewById(R.id.nobtn); no.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); ImageView close = (ImageView) dialog.findViewById(R.id.ivClose); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }); listops listops = new listops(TabsActivity.this); CommonUtilities.logMe("logging in as: " + listops.getString("firstname")); TextView name = (TextView) findViewById(R.id.welcome); name.setText("Welcome, " + listops.getString("firstname")); TextView logoutname = (TextView) findViewById(R.id.logoutname); logoutname.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(TabsActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.dialog_logout); dialog.getWindow().setBackgroundDrawable( new ColorDrawable(getResources().getColor(android.R.color.transparent))); dialog.setContentView(R.layout.dialog_logout); Button yes = (Button) dialog.findViewById(R.id.yesbtn); yes.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MyToast.popmessagelong("Logging out... ", TabsActivity.this); SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(Constants.loginkey, ""); editor.commit(); listops listops = new listops(TabsActivity.this); //make sure to remove the downloaded schools Intent intent = new Intent(TabsActivity.this, LoginActivity.class); startActivity(intent); ArrayList<Schoolinfomodel> ls = new ArrayList<Schoolinfomodel>(); listops.putdrilllist(ls); listops.putservicelist(ls); listops.putinstallllist(ls); ArrayList<PendingUploadModel> l = new ArrayList<PendingUploadModel>(); listops.putpendinglist(l); finish(); } }); Button no = (Button) dialog.findViewById(R.id.nobtn); no.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); ImageView close = (ImageView) dialog.findViewById(R.id.ivClose); close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }); ll1 = (LinearLayout) findViewById(R.id.ll1); ll2 = (LinearLayout) findViewById(R.id.ll2); ll3 = (LinearLayout) findViewById(R.id.ll3); ll4 = (LinearLayout) findViewById(R.id.ll4); ll5 = (LinearLayout) findViewById(R.id.ll5); ll6 = (LinearLayout) findViewById(R.id.ll6); ll1.setBackgroundColor(getResources().getColor(R.color.White)); llPickSchools = (LinearLayout) findViewById(R.id.llPickSchool); llDrills = (LinearLayout) findViewById(R.id.llDrills); llServiceCalls = (LinearLayout) findViewById(R.id.llServiceCalls); llNewInstalls = (LinearLayout) findViewById(R.id.llNewInstalls); llPendingUploads = (LinearLayout) findViewById(R.id.llPendingUploads); frameLayout = (FrameLayout) findViewById(R.id.frame); }
From source file:com.example.search.car.pools.welcome.java
public void dialog(String name, final String[] arr, final TextView tv) { final Dialog dialog = new Dialog(welcome.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.setContentView(R.layout.dialog); final ListView list = (ListView) dialog.findViewById(R.id.list_cities); DialogAdapter adapter = new DialogAdapter(welcome.this, arr); list.setAdapter(adapter);/* www.j a va2s. com*/ final TextView t = (TextView) dialog.findViewById(R.id.tv_1_send_msg); t.setText("Select " + name); Typeface tf = Typeface.createFromAsset(welcome.this.getAssets(), "AvenirLTStd_Book.otf"); t.setTypeface(tf); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { tv.setText(arr[position]); dialog.dismiss(); } }); final RelativeLayout l_close = (RelativeLayout) dialog.findViewById(R.id.l_close); l_close.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub dialog.dismiss(); } }); dialog.show(); }
From source file:org.projectbuendia.client.ui.dialogs.OrderDialogFragment.java
@Override public @NonNull Dialog onCreateDialog(Bundle savedInstanceState) { View fragment = mInflater.inflate(R.layout.order_dialog_fragment, null); ButterKnife.inject(this, fragment); mGiveForDays.addTextChangedListener(new DurationDaysWatcher()); Bundle args = getArguments();/*from w w w. ja v a 2 s . co m*/ boolean newOrder = args.getBoolean("new"); String title = getString(newOrder ? R.string.title_new_order : R.string.title_edit_order); final String orderUuid = args.getString("uuid"); populateFields(args); final Dialog dialog = new AlertDialog.Builder(getActivity()).setCancelable(false) // Disable auto-cancel. .setTitle(title) // The positive button uses dialog, so we have to set it below, after dialog is assigned. .setNegativeButton(R.string.cancel, null).setView(fragment).create(); ((AlertDialog) dialog).setButton(Dialog.BUTTON_POSITIVE, getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { onSubmit(dialog); } }); mDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onDelete(dialog, orderUuid); } }); // Hide or show the "Stop" and "Delete" buttons appropriately. Long stopMillis = Utils.getLong(args, "stop_millis"); Long nowMillis = Utils.getLong(args, "now_millis"); Utils.showIf(mDelete, !newOrder); // Open the keyboard, ready to type into the medication field. dialog.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); mMedication.requestFocus(); return dialog; }