【问题标题】:How can I get the information entered into custom dialog in the fragment?如何获取在片段的自定义对话框中输入的信息?
【发布时间】:2019-05-09 03:46:39
【问题描述】:

我有启动 OnClickLister 事件以在片段中启动 DialogCustom 的 buttonStart。

StartActivityFragment.kt

在 DialogNewCounter(自定义对话框)中,我从 editTextNameDialogNewCounter 获得响应,我想将其发送到片段,以传递我使用 RequestDialog 接口的信息。

dialog_new_counter.xml

DialogNewCounter.kt

在片段(第一张照片的StarActivityFragment.kt)中,我实现了Resquest Dialog接口并覆盖了onRequest方法。编译它会给我以下错误。

有人可以帮助我,我有几天遇到这个问题。非常感谢你

【问题讨论】:

  • 嘿,我刚刚发布了我的答案,试试看,如果您有任何疑问,请告诉我。
  • @Fahed Hermoza,请在提问时关注proper format,我认为否决票是因为代码示例使用图像而不是文本

标签: kotlin dialog


【解决方案1】:

试试这个

进行两项更改

1.更改对话框显示代码。

从此:-

val dialog = DialogNewCounter()
dialog.show(activity?.supportFragmentManager, "dialog_counter")

至此:-

val dialog = DialogNewCounter()
dialog.show(childFragmentManager, "dialog_counter")

2。按钮点击时DialogNewCounter() 的第二次更改

从此:-

(activity as RequestDialog).onRequest(result)

至此:-

(parentFragment as RequestDialog?)!!.onRequest(result)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-08
    • 2017-02-16
    • 1970-01-01
    • 1970-01-01
    • 2013-03-12
    • 1970-01-01
    • 2020-12-12
    相关资源
    最近更新 更多