Jdr*_*uwe 9 android android-fragments android-dialogfragment
我无法绕过某些东西,但让我先描述一下我的设置:

我有一个引用3个片段的活动,每个片段都会在正确的时间显示出来.这就是ChildrenSpecificationFragment的外观:

如果用户单击浮动操作按钮,则会打开以下DialogFragment:

我在新的材料设计指南中找到了以下信息:https://www.google.com/design/spec/components/dialogs.html#dialogs-full-screen-dialogs
避免使用以下对话框:在对话框中打开其他对话框.包含滚动内容,尤其是警报.相反,请考虑针对阅读或与大量内容进行交互而优化的备用容器或布局.
例外情况包括:全屏对话框可能会打开其他对话框,例如拣货员,因为它们的设计可以容纳额外的材料层,而不会显着增加应用程序感知的z深度或视觉噪音.
这是我的问题开始的地方."添加子项"对话框具有可滚动内容(在横向模式下),当用户单击"出生日期"时,日期选择器将打开.
我试图找到一种方法来实现一个全屏对话框(如准则中),该对话框具有对ChildrenSpecificationFragment的回调,以便我可以将子项添加到RecyclerView.
我希望我的探索是明确的,并且非常感谢能够引导我找到解决方案的任何意见.提前致谢!
我没有看到你的帖子中的代码。所以我猜测你的代码结构是一个开始。首先使用侦听器构建对话框并处理 setPositiveButton() 和 onClick 事件。
代码建议:
public class ChildrenSpecificationFragment extends Fragment {
...
public void passData(Object obj) {
}
class SubChildFragment extends Fragment {
AlertDialog.Builder builder = new AlertDialog.Builder(thisContext);
...
// Add the buttons...
builder.setPositiveButton("Save", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
...
passData(Object obj); // pass data to the outer fragment class
Run Code Online (Sandbox Code Playgroud)
笔记:
SubChildFragment例如, 是从 Fragment 派生的内部类。passData它可以调用外部类中的公共方法()ChildrenSpecificationFragment来传递您需要的任何数据。添加子全屏片段
为了显示全屏对话框,我认为有一个很好的 Google 网页@ Dialog-Fullscreen。搜索文本“全屏显示对话框或作为嵌入式片段显示对话框”。
| 归档时间: |
|
| 查看次数: |
6730 次 |
| 最近记录: |