search

Home  >  Q&A  >  body text

android - Activity中通过Fragment的对象调用其方法时,无法将数据设置进入Fragment

怪我咯怪我咯2858 days ago523

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 16:05:42

    1. Activity can directly reference Fragment.

    2. Your calling method can change the member variables of Fragment. A better way is to write an interface Activity to communicate with Fragment

    3. There are two possibilities for your log to be empty: one is that the Activity or Fragment has been recycled and re-created, and the previously changed attributes have not been restored. For related technical points, you can view Activity data recovery; the other is that you have changed and printed the log in two Fragments. citations.

    4. It is recommended to post more code to check the problem.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 16:05:42

    Too little sticky code. Based on this, it is suspected that the Activity has been rebuilt, or the fragment in the Activity has been rebuilt, but the newly created Activity or Fragment has not been executed using the setOptions
    可以打印Fragment的构造函数和setOptions function mentioned here to check

    reply
    0
  • Cancelreply