且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将数据从Activity发送到Fragment?(Android)

更新时间:2023-01-01 16:34:03

您可以像这样从片段中访问这些实例:

You can access these instances from your fragment like this:

字符串cityFieldFragment =(活动为YourActivity).cityField;

字符串updatedFieldFragment =(活动为YourActivity).updatedField;

如果我理解这一权利,则该片段存在于您的活动中,因此您可以从中访问数据,只需确保实例是公共的即可.

If I understood this right, the fragment lives in your activity, so you are able to access the data from it, just make sure that the instances are public.