一个接一个地实现两个自定义对话框的最佳方法是什么?
通过各种教程的帮助,我成功编写了一个自定义对话框,该对话框显示由本地数据库中的记录填充的列表视图。我已经设置了单击侦听器,并弄清楚如何通过将光标设置在返回的位置来检索单击的列表视图项处的记录,依此类推...现在我想做的是,在单击某个项目时关闭此对话框,并且自动打开一个新对话框,其中光标的内容作为表的名称,从中重新填充新的列表视图。我想知道是否有人知道在应用程序结构方面做到这一点的最佳方法。 目前,我正在调用我的对话框以在我的活动中显示,如下所示:
public void onClick(View view) {
switch(view.getId()) {
case R.id.pickerbutton:
showDialog(DIALOG_PICK_CATEGORY);
break;
}
}
protected Dialog onCreateDialog(int id) {
dialog = null;
switch(id) {
case DIALOG_PICK_CATEGORY:
CustomDialogList.Builder customBuilder = new
CustomDialogList.Builder(SendCookieActivity.this);
customBuilder.setTitle(R.string.category);
dialog = customBuilder.create();
break;
}
return dialog;
}
显示此对话框后,用户从 CustomDialogList 对话框中选择一个类别。我很难思考如何做到这一点,以便在选择类别后,该对话框被关闭(或看起来像是被关闭),并且出现带有新填充项目的相同对话框(或者也可以是一个全新的对话框) 。当有人按下后退按钮时,将显示上一个对话框。将其视为一个文件浏览器,但只有两个深度级别。我想继续使用我的 CustomDialogList,因为我已经自定义了它的外观以匹配我的应用程序中的其他所有内容。除了代码之外或者代替代码之外,也许可以帮助我解决这个问题的是一些之前如何实现这种类型的 UI 流程的图表以及一些伪代码。
谢谢。
through the help of various tutorials, I've managed to write a custom dialog that displays a listview populated by records from a local database. I have set click listeners and figured out how to retrieve the record at the listview item clicked by setting the cursor at the position returned and so on...Now what I want to do is, dismiss this dialog when an item is clicked, and automatically open a new dialog with this cursor's content as the name of the table from which to re-populate the new listview. I'd like to know if anyone knows the best way of doing this in terms of application structure.
Currently, I am calling my dialog to show in my Activity like this:
public void onClick(View view) {
switch(view.getId()) {
case R.id.pickerbutton:
showDialog(DIALOG_PICK_CATEGORY);
break;
}
}
protected Dialog onCreateDialog(int id) {
dialog = null;
switch(id) {
case DIALOG_PICK_CATEGORY:
CustomDialogList.Builder customBuilder = new
CustomDialogList.Builder(SendCookieActivity.this);
customBuilder.setTitle(R.string.category);
dialog = customBuilder.create();
break;
}
return dialog;
}
After this dialog is shown, the user picks a category from the CustomDialogList dialog. I am having a hard time thinking of how to make it so that after the category is picked, this dialog is dismissed (or looks like it's dismissed) and the same one with newly populated items appears (or can be a completely new dialog too). and when someone presses the back button, the previous dialog is shown. Think of it as a file explorer but with only two levels of depth. I'd like to keep using my CustomDialogList because I have customized its look to match everything else in my app. Perhaps what would help me with this problem besides or instead of code, would be some diagrams of how this type of UI flow has been implemented before along with some pseudo code.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您的自定义对话框扩展了
Dialog
(或其子类之一)。让您的Activity
实现DialogInterface.onDismissListener
。然后,在使用... 创建对话框后,在显示对话框之前使用
dialog.setOnDismissListener(this);
。您的
Activity
将必须实现...Assuming your custom dialog extends
Dialog
(or one its sub-classes). Have yourActivity
implementDialogInterface.onDismissListener
. Then after you create the dialog with......use
dialog.setOnDismissListener(this);
before you show it.Your
Activity
will have to implement...当我过去不得不这样做时,我让对话框的 onCancel 打开新对话框。
When I have had to do this in the past, I have the onCancel for the dialog open the new dialog.