How can I pass data from activity to the dialogFragment that activity invoked?

后端 未结 3 1863
臣服心动
臣服心动 2021-02-05 11:58

In my application I have a form the user fills in. Pressing \"save\" the data will be saved to the local database. I want to add a confirm dialog for the user to review the deta

3条回答
  •  名媛妹妹
    2021-02-05 12:26

    Perhaps not the most pretty/elegant method, but you could make those bits of information public static and then reference them from the dialog.

    In the activity/fragment where you gather the data:

    public static String A
    public static String B
    public static String C
    

    And grab it in the dialog fragment like so (apologies if I'm explaining something you already know):

    your_activity/fragment_classname.A
    your_activity/fragment_classname.B
    your_activity/fragment_classname.C
    

提交回复
热议问题