2011-05-16 15 views
0

我有一個tabhost在我的主要活動中有2個選項卡,對於第二個選項卡,我添加了一個列表視圖意圖作爲內容。 一切工作正常。 現在我已經重寫onCreateDialog()方法列表視圖(第二選項卡的),當我做出showDialog(MY_DIALOG);方法onCreateDialog()調用獲取調用,但我得到一個警告,在logcat的像在選項卡式活動內showDialog問題

"WARN/InputManagerService(58): Window already focused, ignoring 
focus gain of: [email protected]" 

任何人可以幫助我如何在tabhost的活動中顯示對話框。

//編輯提前

protected Dialog onCreateDialog(int id) { 
Log.v(Constants.LOGTAG, " " +CLASSTAG+ " onCreateDialog(): +++ START +++"); 
AlertDialog.Builder builder = new AlertDialog.Builder(this);   
switch (id) { 
    case DIALOG_MY_TYPES: { 
     Log.v(Constants.LOGTAG, " " +CLASSTAG+ " onCreateDialog(): DIALOG_MY_TYPES"); 
     CharSequence[] items = {"option1", "option2", "option3"}; 
     builder.setTitle("Select").setItems(items, 
      new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int item) { 
        Log.d(CLASSTAG, "item selected = " + item); 
        dialog.cancel(); 
       } 
      }).setNegativeButton("Cancel", 
      new DialogInterface.OnClickListener() { 
       public void onClick(DialogInterface dialog, int id) { 
        Log.d(Constants.LOGTAG, " "+CLASSTAG+" Cancel button is clicked"); 
        dialog.cancel(); 
       } 
      }); 
    } 

}//switch 
alert = builder.create(); 
Log.v(Constants.LOGTAG, " " +CLASSTAG+ " onCreateDialog(): +++ END +++"); 
return super.onCreateDialog(id);     
} 

感謝。 -Nehatha

+0

你可以顯示'onCreateDialog'方法的代碼。 – 2011-05-16 16:16:50

+0

@Tanmay,用代碼 – 2011-05-16 16:40:52

回答

0

更改return super.onCreateDialog(id);return alert;。我假設你Activity的其他部分調用了showDialog(int)。如果沒有,那麼你要麼這樣做,要麼從onCreateDialog(id)調用返回的Dialog上的show方法。

+0

更新了原來的問題Hi Bruce,非常感謝,它工作得很好 – 2011-05-16 17:06:13