选项卡式活动中的 showDialog 问题
我的主要活动中有一个带有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
return super.onCreateDialog(id);
更改为returnalert;
。我假设您的 Activity 的其他部分正在调用 showDialog(int)。如果没有,那么您要么想要这样做,要么在 onCreateDialog(id) 返回的 Dialog 上调用 show 方法。Change
return super.onCreateDialog(id);
toreturn 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).