选项卡式活动中的 showDialog 问题

发布于 2024-11-07 17:04:15 字数 1676 浏览 6 评论 0原文

我的主要活动中有一个带有 2 个选项卡的选项卡主机,对于第二个选项卡,我添加了一个列表视图意图作为内容。 一切正常。 现在,当我调用 showDialog(MY_DIALOG); 方法 onCreateDialog()< 时,我已经重写了列表视图(第二个选项卡)中的 onCreateDialog() 方法/code> 正在被调用,但我在 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);                
}

提前致谢。 -尼哈莎

I have a tabhost with 2 tabs inside my main activity, for the 2nd tab i added a list view intent as content.
Everything is working fine.
Now I have overriden onCreateDialog() method in the list view (2nd tab's), when i made a call to showDialog(MY_DIALOG); method onCreateDialog() is getting called but I'm getting a warning in the LogCat like

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

Can anybody help me how to show the dialog box inside tabhost's activity.

//edit

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

Thanks in advance.
-Nehatha

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷鸟归林 2024-11-14 17:04:15

return super.onCreateDialog(id); 更改为 returnalert;。我假设您的 Activity 的其他部分正在调用 showDialog(int)。如果没有,那么您要么想要这样做,要么在 onCreateDialog(id) 返回的 Dialog 上调用 show 方法。

Change return super.onCreateDialog(id); to return alert;. I assume some other part of your Activity is calling showDialog(int). If not, then you'll either want to do so, or call the show method on the returned Dialog from onCreateDialog(id).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文