AlertDialog主题

时间:2012-04-29 07:02:36

标签: android alertdialog

我正在使用

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

在我的活动中,它正确显示对话框, 但是当对话框出现时,它会在中间显示我的项目名称,如下图所示,所以,在按下后退按钮之前我无法做任何事情。

我的项目名称是:LMP

My project name is: LMP

有什么建议吗?

================== 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;
    }

===========================第二次更新================== =================

投放后:

使用visibility ="gone"的xml布局并添加以下行:

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);
....
}}

获得的结果如下图所示:

1 个答案:

答案 0 :(得分:0)

您显示对话框的方式非常糟糕(您不应仅使用新活动来显示对话框)。我建议你改为dialogfragments