Fragment setArguments&getArguments的作用

    xiaoxiao2021-03-25  167

    Fragment setArguments&getArguments的作用

    使用说明 在创建Fragment之前,可以通过setArguments设置Bundle类型参数,在Fragment回调onCreateView里面可以解析该参数,所以可以通过该方法在创建/使用Fragment之前传递参数

    注:Bundle是一个键值对

    官方文档说明 setArguments: public void setArguments (Bundle args) Supply the construction arguments for this fragment. This can only be called before the fragment has been attached to its activity; that is, you should call it immediately after constructing the fragment. The arguments supplied here will be retained across fragment destroy and creation.

    getArguments: Return the arguments supplied when the fragment was instantiated, if any.

    转载请注明原文地址: https://ju.6miu.com/read-5962.html

    最新回复(0)