1

I have a problem in alert dialog builder. I can't change alert box background color. Please resolve my problem.

I write some code for alert builder to show alert message and icon, but I can't set background:

protected Dialog onCreateDialog(int id) {

    // TODO Auto-generated method stub
    switch (id) {
        case 0:

            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            builder.setIcon(R.drawable.alert);
            builder.setTitle("*Select Valid Location");
            builder.setCancelable(false)
                .setPositiveButton("Ok", null);
            AlertDialog alert = builder.create();

            alert.show();
            break;
Delimitry
  • 2,987
  • 4
  • 30
  • 39
NareshRavva
  • 823
  • 3
  • 21
  • 50
  • possible duplicate of [Creating Custom Alert box in android](http://stackoverflow.com/questions/3928562/creating-custom-alert-box-in-android) –  Dec 24 '11 at 10:34
  • Just a heads up, you will want to return the dialog after creating it and not call `show()` since the framework will do that for you :) – Chase Dec 24 '11 at 10:34

2 Answers2

0

Just create any Activity you want with whatever layout you want, and apply android:theme="@android:style/Theme.Dialog" to your <application> tag in your manifest
The answer was copied from a similar question here

Community
  • 1
  • 1
Shadow
  • 6,161
  • 3
  • 20
  • 14
  • Please don't copy answers, rather leave a comment noting that there is a possible duplicate instead. –  Dec 24 '11 at 10:33
  • What do you mean by layout compressed? Can you give a screenshot? – Shadow Dec 24 '11 at 12:45
0

For this You need to create a style.xml in value folder and simply make your Dialog with style

http://androblip.huiges.nl/2010/05/09/theme-android-dialog/

check this link it will help You...

Rishi
  • 44
  • 2