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
Related
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
I am writing an Android app where I need to put bigger text on the Buttons of Dialog windows programatically.
I saw that there are two options to set (positive, negative or neutral) buttons on an AlertDialog.Builder:
setPositiveButton(CharSequence text, DialogInterface.OnClickListener listener)
setPositiveButton(int textId, DialogInterface.OnClickListener listener) and
In option 1, I can only set the text and in option 2, I can use resource id of the text value.
But none of the options allow me to add a styled button.
Is there some other way?
There is no need for you to create a custom view.
The dialog builder create method returns a AlertDialog object that gives you access to the buttons.
AlertDialog.Builder alert = new AlertDialog.Builder(YOUR_CONTEXT);
AlertDialog dialog = alert.create();
// Positive
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(THE_SIZE);
// Negative
dialog.getButton(DialogInterface.BUTTON_NEGATIVE).setTextSize(THE_SIZE);
OF course, you can always go for your custom View to show to the user when the dialog is created, by using:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setView(yourCustomView);
However, take on count that creating your own custom View, means you have to inflate your own layout, create your buttons inside of it and handle the proper click actions, just like you do in a regular activity, this is the way to go if you want to modify any of the "default" views in your dialog...
Hope this helps...
Regards!
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 want to have a popup dialog with OK/Cancel and two spinners.
(1) Is this possible?
(2) Has this been done in any other apps?
Thanks
Yes that's possible take a look at how to implement custom dialogs:
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog