2012-04-29 70 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