I want to collect user input from a dialog box caller alert1.
AlertDialog.Builder alert1=new AlertDialog.Builder(context);
LinearLayout layout1=new LinearLayout(context);//context is an object of type Context previously initialised to 'this'
layout1.addView(box1);//box1 is an EditText
alert1.setView(layout1);
alert1.show();
this however makes the edittext appear reallys small. but if i do this instead
alert1.setView(box1);
and get rid of the LinearLayout all together it appears right but i cant add anymore custom ui controls to this alert box. Can someone tell me where i'm wrong
its for target android 4.0
also i tried both orientations for the linear layout..
Try to set LayoutParams in the LinearLayout with the following code linearLayout.setLayoutParams(params);.
Related
I noticed that if I create a standard two-button AlertDialog using the builder and one button contains text that spans more than one line and the other button fits on one line, then the button sizes are mismatched. Only the two-line text button grows, and it looks most unpolished:
Is there an easy workaround to still use the AlertDialog builder and coax the button sizes to match?
You can create your own Dialog with a self build layout file. So you can manipulate the text, backgrounds, etc of the bottom buttons as you like.
Kr
I presumed this is an Android bug/feature and reported it.
Hi I want to make a custom dialogue box for my android application and want to populate it with buttons, check boxes and such kind of items.
I have followed the tutorial from android developers website, but that is not what I want, actually I want to customise the background and size of the dialogue box.
Please if any body could give me a head start, Plus I want to know when I design a background for that box, what dimensions and pixel numbers I use so that it may run the same in Galaxy Note, Galaxy S and tablets and other mobile phones running android.
Here is the picture of customised dialogue box. Like that I want to work out something.
Yes this is a good question. You must use a custom dialog with a transparent bg theme like these:
Dialog dialog = new Dialog(mContext, android.R.style.Theme_Translucent_NoTitleBar);
dialog.setContentView(R.layout.custom_dialog);
dialog.show();
where custom_dialog will be your XML for the dialog layout, and as far as dimensions go you should really test your app on a number of different screen resolution devices to ensure it displays as you want.
On occasion I have wanted to create a fully customized dialog such as the one you've shown.
When I had to do it, I fought for a while trying to make it a Dialog. In the end I found it was far easier to just wrap my dialog in its own activity, set it to theme transparent in the manifest, and make the layout xml file such that there was transparent space around the edges. That was the easiest way for me to get rid of all of the default dialog formatting (i.e. the frame that it comes in if you do it with the setContentView() route)
So while it is not technically a dialog any more, to the user it serves the same purpose.
I have a standard (not custom, no layout) AlertDialog with literally just an EditText as its view and two buttons (OK and cancel.)
When there's a problem with the input, I show an error message that ends up being three lines of text, which occludes the OK and cancel buttons. The error text does disappear once the user types something, but I'd sure like the cancel button to be visible.
Is there any (easy) way of changing the placement of the error text?
Unfortunately, not without some customization. The internal PopupWindow managed for the error display is called with showAsDropDown(), which let's Android decide where to display the view in relation to it's anchor (the error icon, in this case) and it will always be below the view unless there is not enough window space. You would have to create (albeit fairly simple) subclass of EditText that displays the internal PopupWindow using showAtLocation() instead.
Here's the link to the TextView source to hopefully help out if you want to try that. The setError() and showError() methods are what you would be after overriding.
HTH
Friends;
How To Set ProgressDialog Second Progress Bar Like Below Images.
thanx.
The screenshot you show is not a ProgressDialog, it is just a Dialog with a custom layout.
What you need, in order to show a dialog like the one in your picture is:
A custom layout defining two ProgressBars, one below the other.
Create a Dialog and call yourDialog.setContentView(R.id.yourCustomLayout)
That's it, that's all you need
I would like to call your attention to the fact that you can also show the second progress in the same ProgressBar as the first, by using yourProgressBar.setSecondaryProgress(progressValue).
Am I right in assuming that this is a layout issue? You want to have that second progress below the box that it is currently in?
If that's the case, use a relative layout and in the layout xml add this line to the progess bar:
android:layout_below="...."
In the quotation marks enter the id of the box that they are currently in.
Is it possible to have an Android Alert box or Dialog off-center? I have tried everything that comes to mind, including making a custom Dialog activity and theme (extending Android:Theme.Dialog), but I have not been able to move it from it's centered position.
Yes you can make the background translucent and fill the entire view, then nest a visible layout within that you can use layout_gravity="top|left" on.
A little off topic, but if you just want to display text, an easier way is to use a toast.
Toast toast = new Toast(new ContextThemeWrapper(getApplicationContext(), R.style.YourDialogStyle));
toast.setGravity(Gravity.LEFT|Gravity.TOP, 0,0);
PopupWindow? An example can be found here: http://www.anddev.org/how_to_create_a_popupwindow-t1259.html