显示选项卡式活动内的对话框问题



我的主要活动中有一个带有 2 个选项卡的选项卡主机,对于第二个选项卡,我添加了一个列表视图意图作为内容。一切正常。现在我已经在列表视图(第二个选项卡)中覆盖了onCreateDialog()方法,当我调用showDialog(MY_DIALOG);方法时onCreateDialog()正在被调用,但我在 LogCat 中收到警告,例如

"WARN/InputManagerService(58): Window already focused, ignoring 
focus gain of:  com.android.internal.view.IInputMethodClient$Stub$Proxy@44ee6948"

任何人都可以帮助我如何在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);                
}

提前谢谢。-内哈塔

return super.onCreateDialog(id);更改为return alert; 。 我假设你的活动的其他部分正在调用showDialog(int)。 如果没有,那么你要么想要这样做,要么从onCreateDialog(id)调用返回的对话框上的show方法。

最新更新