2012-04-29 31 views
4

我使用AlertDialog主题

<activity android:name =".ShowingDialog" 
      android:theme="@android:style/Theme.Dialog" /> 
在我的活动

并正确显示的对话框中, 但出现的对话框时,它显示我在中间我的项目名称,如上图的下方,所以,我直到我按下返回按钮才能做任何事情。

我的项目名称为:LMP

My project name is: LMP

有什么建议?

==================更新=========================== ==============

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

=========================== 2日更新===================================

把后:

XML布局visibility ="gone"并加入这一行:

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

获得在该图中所示的结果:

+3

由于缺少内容布局,这可能是活动的标题。使用这里的答案之一:http://stackoverflow.com/questions/2591036/how-to-hide-the-title-bar-for-an-activity-in-xml-with-existing-custom-theme – 2012-04-29 07:04:20

+0

@ MarekSebera听起来像是对我的回答... – Hassan 2012-04-29 07:06:44

+0

@MarekSebera谢谢你的回答,但这并没有出现在标题栏中,它显示在屏幕中间!我必须按回来按钮来使用我的应用程序?! – Monerah 2012-04-29 07:12:17

回答

0

你显示一个对话框的方式实在是太差了(你不应该使用一个新的活动只显示一个对话框)。我建议你改为看看dialogfragments