android-alertdialog

AlertDialog disappears when touch is outside [Android] [duplicate]

你说的曾经没有我的故事 提交于 2020-05-08 18:51:23
问题 This question already has answers here : Prevent Android activity dialog from closing on outside touch (19 answers) android 4.0 Dialog gets canceled when touched outside of dialog window (3 answers) Closed 3 years ago . I'm using an Alert Dialog on my application, but it keeps hiding when the users touches outside it. Here is my code: public class DialogMessageEnd extends DialogFragment { String winner; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder

Wrong button style when creating AlertDialog with androidx DialogFragment

你。 提交于 2020-02-02 03:08:09
问题 Here is my root style: <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar"> And here is how I create dialog: override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return AlertDialog.Builder(requireActivity()) .apply { setMessage(R.string.dialog_delete_service_message) setPositiveButton( R.string.dialog_delete_service_positive_button ) { _, _ -> listener?.onConfirmed() } setNegativeButton(R.string.dialog_delete_service_negative_button, null) }.create() }

Alert message is not displaying in alert dialog box?

自古美人都是妖i 提交于 2020-01-25 03:13:45
问题 I want to display the alert dialog box to device screen size. I got the solution through this link How to make an alert dialog fill 90% of screen size? I use the solution given there, it works just fine but my alert message is displaying in very small size. we can't even make out the message in landscape orientation. I have used the following code. AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.app_description).setPositiveButton( "Ok", new

Apply style to Alert Dialogs

泄露秘密 提交于 2020-01-24 20:20:08
问题 I decided to try material alert dialogs on android. The problem I am having is when I try to apply some styles. Checking the docs, I found this: <item name="materialAlertDialogTheme">@style/ThemeOverlay.MaterialComponents.MaterialAlertDialog</item> So I decided to try this: <style name="BaseTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar"> <item name="materialAlertDialogTheme">@style/Theme.App.MaterialDialogAlert</item> </style> <style name="Theme.App.MaterialDialogAlert" parent=

AlertDialog with OK/Cancel buttons

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-24 03:12:25
问题 I create this AlertDialog: String msg = "Connessione lenta o non funzionante"; AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(HomePage.this).create(); alertDialog.setTitle("Timeout connessione"); alertDialog.setMessage(msg); alertDialog.show(); I want to add OK and Cancel buttons. I searched here on StackOverflow but setButton method seems to be deprecated. I also found setPositiveButton and setNegativeButton for AlertDialog.Builder but even them seem to be deprecated. 回答1:

Call alertDialog onStop/onPause

醉酒当歌 提交于 2020-01-23 13:33:28
问题 @Override protected void onStop() { super.onStop(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Test message") .setCancelable(true) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); } This obviously isn't working, as soon as dialog is shown - activity is stopped (dialog disappears). How to solve this issuse? I want

AlertDialog button doesn't work and it doesn't dismiss

妖精的绣舞 提交于 2020-01-22 03:46:13
问题 I have this AlertDialog that should be a duel between two players. It shows an image of a duel and after three seconds, thanks to a timer, it shows a "BANG" image. When the "BANG" image appears, the player must press the "BANG" button and the fester player wins. My problem is that the listener on the button doesn't work and i can't dismiss the alertDialog. This is the code package com.example.root.gbu; import android.app.Activity; import android.app.AlertDialog; import android.content.Context

How to check edit text is empty [duplicate]

只谈情不闲聊 提交于 2020-01-17 04:01:05
问题 This question already has answers here : Check if EditText is empty. [closed] (30 answers) Closed 6 years ago . I am developing a application in which if i click a button it woul d check that all the edit text are empty or something written and providing similar alert box for that message.I had made a method and calling it in Onclick event.But i am not able to get the desired result as syntax error is not dr even logcat not showing any error please help me out...Thanks in advance..

how to cancel/stop asyntask with alert dialog

不羁岁月 提交于 2020-01-16 18:38:13
问题 here is my onPostExecute() method @Override protected void onPostExecute(Void unused) { TextView tvStatus=(TextView) layoutSendDialog.findViewById(R.id.tvPupukSendStatus); if (bNodata){ tvStatus.setText("No data to be sent!!!"); }else { if (bError && stopResend<5){ tvStatus.setText("Gagal terkirim di record #"+String.format("%d",recordCount)+" || ReSend : "+String.format("%d",stopResend)+" Kali "); //SystemClock.sleep(10000); //for (int i=1; i<=2; i++){ final AlertDialog dlg =

how to use alertdialog

戏子无情 提交于 2020-01-16 16:27:40
问题 package com.progme.wallkon; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; public class NextActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.next); ImageView im1;