【发布时间】:2019-10-22 09:12:57
【问题描述】:
我曾尝试从从 Fragment 实例化的 Activity 发送数据。将数据从 Activity 发送回 Fragment。我尝试了以下代码
片段:
Instantiated the Fragment
Intent intent = new Intent(Fragement.this,Activity);
startActivity(intent);
活动:
Intent intent = new Intent(Activitiy.this, Fragment);
intent.putExtra("Sent", "Something");
setResult(RESULT_OK, intent);
finish();
将结果发送到片段
In Fragment trying to implement onActivityResult but not even able to define the method.
【问题讨论】:
-
您可以使用视图模型并观察活动中的数据
标签: android android-fragments android-intent