4

I'm using

<activity android:name =".ShowingDialog" 
          android:theme="@android:style/Theme.Dialog" />

in my activity and it shows the dialog correctly, but when the dialog appears it shows me my project name in the middle as shown in picture below, so, I can't do anything until i press back button.

My project name is: LMP

My project name is: LMP

Any suggestions?

==================update =========================================

import android.app.Activity; 
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.widget.Button;
import android.widget.Toast;

public class ShowingDialog extends Activity {

    boolean b;
    String CancelMsg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    //For Sending SMS with cancel Request


    //For Notification -1-
            final AlertDialog alertDialog = new AlertDialog.Builder(this).create();
            alertDialog.setTitle("...");
            alertDialog.setMessage("...");


    // For Notification -2- 
            final AlertDialog alertDialog2 = new AlertDialog.Builder(this).create();
            alertDialog2.setTitle("...");
            alertDialog2.setMessage("...");

                    alertDialog.setButton("...", new DialogInterface.OnClickListener() {
                       public void onClick(DialogInterface dialog, int which) {


                           // If yes move the plaintiff to MyPage act.
                           Intent intent= new Intent(ShowingDialog.this,LMPActivity.class);
                           startActivity(intent);

                        ;

                       }
                    });

                    alertDialog.setButton2("...",
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog,
                                        int which) {
                                alertDialog2.setButton("...", new DialogInterface.OnClickListener() {
                                           public void onClick(DialogInterface dialog, int which) {

                                                 CancelMsg = "Case_ID cancel";
                                               if (!b) {
                                                    try {
                                                        // Should write server number here + the chatting must be pushed above 
                                                        sendSMS("0000", CancelMsg);
                                                        Toast.makeText(ShowingDialog.this, "...", Toast.LENGTH_LONG)
                                                                .show();
                                                    } catch (Exception e) {
                                                        // TODO Auto-generated catch block
                                                        Toast.makeText(ShowingDialog.this, e.getMessage(),
                                                                Toast.LENGTH_LONG).show();
                                                    }

                                                }
                                           }
                                        });

                                        alertDialog2.setButton2("...", new DialogInterface.OnClickListener() {
                                           public void onClick(DialogInterface dialog, int which) {
                                            // here you can add functions
                                            // Do nothing 




                                           }
                                        });

                                        alertDialog2.setIcon(android.R.drawable.ic_dialog_alert);
                                        alertDialog2.show();


                                }
                            });



                    alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                    alertDialog.show();

    }

    public void sendSMS(String number, String msg) throws Exception {
        if (!b) {
            SmsManager smsManager = SmsManager.getDefault();
            smsManager.sendTextMessage(number, null, msg, null, null);
        }
        b = true;
    }

=========================== 2nd updating ===================================

after putting:

xml layout with visibility ="gone" and adding this line:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);



public class ShowingDialog extends Activity {

    boolean b;
    String CancelMsg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    //For Sending SMS with cancel Request
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.showing_dialog);
....
}}

the result obtained is shown in this figure:

Monerah
  • 215
  • 1
  • 5
  • 17
  • 3
    Due to missing content layout, this is probably activity's title. Use one of the answers here: http://stackoverflow.com/questions/2591036/how-to-hide-the-title-bar-for-an-activity-in-xml-with-existing-custom-theme – Marek Sebera Apr 29 '12 at 07:04
  • @MarekSebera Sounds like an answer to me... –  Apr 29 '12 at 07:06
  • @MarekSebera thanks for ur answer, but this doesn't appear in the title bar, it shown in the middle of the screen !!! and i have to press back button to use my app ?!! – Monerah Apr 29 '12 at 07:12
  • @Monerah than show us XML defining layout of dialog's content please – Marek Sebera Apr 29 '12 at 07:14
  • @Monerah: You need to show the code for the `Activity`. MarekSebera is probably right about your `Activity` doesn't have a content (layout) but the answers in the link he provided aren't relevant as far as I can tell. – Squonk Apr 29 '12 at 07:15
  • @MarekSebera I updated my Question please take look at it – Monerah Apr 29 '12 at 07:20
  • @MisterSquonk I updated my Question please take look at iT – Monerah Apr 29 '12 at 07:29
  • @Monerah you don't need to set the Activity's theme to Theme.Dialog just to use a Dialog. You only need to do that when you want to make an Activity look like a Dialog, not merely use one. – Thomas Dignan May 21 '12 at 23:30

1 Answers1

0

Your way of showing a dialog is really bad (you shouldn't use a new activity only to show a dialog). I'd recommend you look into dialogfragments instead.

Warpzit
  • 27,966
  • 19
  • 103
  • 155