Android的全屏对话框回调问题全屏、对话框、回调、问题

2023-09-05 09:24:36 作者:指间微凉.忆成殇

我无法环绕我的头周围的东西,但首先让我介绍我的设置:

I am having trouble wrapping my head around something but let me first describe my setup:

我有引用3个片段的活动,他们每个人得到在正确的时间显示。这是ChildrenSpecificationFragment的外观:

I have an activity that references 3 fragments, each one of them get shown at the correct time. This is how the ChildrenSpecificationFragment looks:

如果用户点击浮动动作按钮下面DialogFragment打开:

If the user clicks the floating action button the following DialogFragment opens:

我发现,在新材料设计方针以下信息:https://www.google.com/design/spec/components/dialogs.html#dialogs-full-screen-dialogs

I found the following information in the new material design guidelines: https://www.google.com/design/spec/components/dialogs.html#dialogs-full-screen-dialogs

避免对话框如下:   从对话框中打开其他对话框。   包含滚动显示的内容,特别提醒。相反,考虑要读取或显著大量的内容进行交互优化,备用容器或布局。

Avoid dialogs that: Open additional dialogs from within a dialog. Contain scrolling content, particularly alerts. Instead, consider alternate containers or layouts that are optimized for reading or interacting with significant amounts of content.

例外情况包括:全屏对话框可能会打开其他对话框,如采摘,因为他们的设计容纳材料的附加层不显著提高应用程序的感知Z深度或视觉噪声

Exceptions include:Full-screen dialogs may open additional dialogs, such as pickers, because their design accommodates additional layers of material without significantly increasing the app’s perceived z-depth or visual noise.

这是我的问题开始。在添加子对话框中有滚动的内容(横向模式)和一个日期选择器打开,当用户点击出生日期。

This is where my problems begin. The 'add child' dialog has scrollable content (in landscape mode) and when the user clicks 'Birth date' a date picker opens.

我试图找到一种方法来实现一个全屏幕对话框(如准则),有回调的ChildrenSpecificationFragment,这样我可以补充孩子的RecyclerView。

I am trying to find a way to implement a full screen dialog (as in the guidelines) that has a callback to the ChildrenSpecificationFragment, so that I can add the child to the RecyclerView .

我希望我的追问是明确的,会大大AP preciate任何投入,这将导致我的解决方案。在此先感谢!

I hope that my questing is clear and would greatly appreciate any input that would lead me to the solution. Thanks in Advance!

推荐答案

我没有看到你的帖子code。所以,我猜你的code结构作为开始。 先用监听器和进程setPositiveButton()和onClick事件建立自己的对话框。

I don't see code from your post. So I am guessing your code structure as a start. First build your dialog with a listener and process setPositiveButton() and the onClick event.

code建议:

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

注:

SubChildFragment ,例如,从片段派生的内部类。它可以调用的公共方法 passData ()在外部类 ChildrenSpecificationFragment 传递你需要的任何数据。 在我使用的是内部类,因为我认为这是你在你的图的意思 SubChildFragment, for example, is an inner class derived from Fragment. It can call the public method passData() in the outer class ChildrenSpecificationFragment for passing any data you need. I am using an inner class because I think this is what you meant in your diagram by

添加子全屏片段

在这种编码技术比开始一个新的活动和意图更容易。

有关显示的全屏对话,有一个很好的谷歌网页,我想@的对话 - 全屏。搜索文本显示一个对话框全屏或嵌入式片段。

For showing fullscreen dialogs, there is a good Google webpage I think @ Dialog - Fullscreen. Search text for "Showing a Dialog Fullscreen or as an Embedded Fragment".

 
精彩推荐
图片推荐