2011-05-16 57 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

相关问题