Android: how to create a transparent dialog-themed activity

You can create a tranparent dialog by this. public class DialogActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle(” “); alertDialog.setMessage(“”); alertDialog.setIcon(R.drawable.icon); alertDialog.setButton(“Accept”, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); alertDialog.setButton2(“Deny”, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { … Read more

how to use number picker with dialog

I have made a small demo of NumberPicker. This may not be perfect but you can use and modify the same. Use a custom dialog and set the number picker. More info @ http://developer.android.com/reference/android/widget/NumberPicker.html public class MainActivity extends Activity implements NumberPicker.OnValueChangeListener { private TextView tv; static Dialog d ; @Override public void onCreate(Bundle savedInstanceState) { … Read more

How can I change default black dim background “color” (not the amount of dim) of Dialog?

This is a workaround but it’s not really a pure solution because background touch is disabled and should be configured manually. First, set custom dialog theme like this. styles.xml <style name=”CustomDialogTheme” parent=”android:Theme.Dialog”> <item name=”android:windowNoTitle”>true</item> <item name=”android:windowIsFloating”>false</item> <item name=”android:windowBackground”>@android:color/transparent</item> </style> Setting windowIsFloating to false forces Dialog view to be expanded to full screen. Setting windowBackground to … Read more

Android Borderless Dialog

Alright, I’ll answer my own question. Basically, instead of using AlertDialog.Builder, create a regular Dialog using it’s constructor, and use a suitable theme instead of the default Dialog theme. So your code would look something like this: Dialog dialog = new Dialog(this, android.R.style.Theme_Translucent_NoTitleBar); Hope this helps someone else.

Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f72ff0 that was originally added here

You are leaking the dialog. You need to call pDialog.dismiss(); in the onPostExecute() method of the async task. You should also put… if(pDialog != null) pDialog.dismiss(); in your onPause() method of the activity on the main thread. This will make sure the window is not leaked, even if your application loses the foreground while doing … Read more

android 4.0 Dialog gets canceled when touched outside of dialog window

Check this method from the Android Developers site for dialog. Try using the dialog.setCanceledOnTouchOutside (boolean cancel) Pass a boolean value to enable/disable dialog behaviour when touched outside of the dialog window. Also go through these links: How do I fire an event when click occurs outside a dialog How to cancel an Dialog themed like … Read more

How to create a completely custom Dialogue/Popup in Android (change overlay colour and dialogue window layout)

I’ve solved this problem and created my own custom popup overlay with a custom coloured semi-transparent overlay background using the following steps: 1 – Create a new xml file in your res/values/ folder and name it styles.xml 2 – Here is where you will define your dialog properties. Here is what mine looks like. If … Read more

Prevent ProgressDialog from being dismissed when I click the search button (Android)

This works (notice I put it on the dialog builder): .setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) { return true; // Pretend we processed it } return false; // Any other keys are still processed as normal } }) Maybe it’s … Read more

JavaFX Alerts and their size

I have made the following workaround: Alert alert = new Alert(AlertType.INFORMATION, “Content here”, ButtonType.OK); alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE); alert.show(); So the window will resize automatically according to the content.