I'm setting a message in a simple alert dialog. I need to know if the user has read all the text inside the dialog or not. Is there any way to set a scroll listener or something in an alert dialog?
Create your custom dialog and then set some listener to your custom View. Here's a good example: http://www.mkyong.com/android/android-custom-dialog-example/
and
https://stackoverflow.com/a/10713501
Related
What I want to do is to show the dialog message but make it still possible to click on the items behind. On any click, the dialog would dismiss
Right now I need to click once to dismiss the dialog and a second time to click on a field.
It is something possible ? Or is there an alternative to using Dialogs?
Edit: Solution found by adding Layout Flags to the window.
In kotlin:
dialog.window?.setLayout(ConstraintLayout.LayoutParams.FLAG_NOT_FOCUSABLE, ConstraintLayout.LayoutParams.FLAG_NOT_FOCUSABLE)
By using Dialog you cannot achieve what you are looking for. instead of using Dialog USE FRAGMENT.
The examples are given in official documentation here.
You Can define a full layout in the background of the dialog and set onClick listener to that layout
I have an app where the user presses a button and a custom spinner is popped so that the user can choose between nine colors. I want the spinner to be dismissed, when the user touches the background (every place on the sreen except from the spinner). Is this possible?
I tried to add an onTouchListener on the image that covers the background and call
dialog.dismiss();
but it does not work.
My spinner is custom Spinner, set in an xml file and popped with:
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.colorchooser);
Thank you in advance
First of all you should be able to add
dialog.setCanceledOnTouchOutside(true);
to accomplish what you want.
But the dismiss() method should also be working, I would guess that the place your are calling dialog.dismiss() is not reachable at the current moment.
I need to display a certain view when an activity starts, and when the user click ckecked to dismiss the view. It look like this
:
Has anyone an idea how can I do this? Any idea is welcome.
Yes, you can use a custom dialog
just create a custom XML and inflate it into your dialog object
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_dialog);
dialog.show();
and then dismiss it by calling dialog.dismiss();
create custom dialog using below link and open it when activity starts...
you need to increase the margin to proivde more spaces
Have a look at custom dialog examples -
custom dialog 1
custom dialog 2
yes, you can use PopupWindow for Creating window
see these tutorila for adding PopupWindow in your Activity:
Using the PopupWindow class in Android apps
Example of using PopupWindow
You could use a RelativeLayout for this. When the user clicks check, the visibility of the 'upper' layout must be set to GONE.
I am working on list Preferences,have to increase the font size in Alert Dialog which pops up when we click on ListPreference element,try to help me in this ........Thanks in Advance
If you wish to adjust the controls in an AlertDialog, you will have to create and add your controls manually.
AlertDialog reference
I have a custom AlertDialog where a user has to set password. There are two edittext views.
I compare them first if they match and if they are more than 3 characters long. If they don't match, I display a toast to alert the user. But after submitting and checking the dialog closes. How can I keep it opened until user inserts the correct values?
I was looking at doing something similar and I could not find a way do this with the standard AlertDialog as it is.
One possible way I found was to not specify any button listeners in your AlertDialog and instead place a view with your own custom buttons that perform the checks and then dismiss the dialog if necessary. I've not yet tried this to see how it works.
Another option is to create your own Custom dialog by subclassing Dialog.
You have to set a global variable like
boolean showAlert = true;
And attach a onClick listener to the AlertDialog and after cheking to see if there is need to show the alert again. If there is a need, you should show it again. You can`t keep it open if the user clicks a button from the AlertDialog. You have to recreate it again.