How to transfer some data to another Fragment?

2018-12-31 19:49发布

How to transfer some data to another Fragment likewise it was done with extras for intents?

7条回答
人气声优
2楼-- · 2018-12-31 20:36

Just to extend previous answers - it could help someone. If your getArguments() returns null, put it to onCreate() method and not to constructor of your fragment:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    int index = getArguments().getInt("index");
}
查看更多
登录 后发表回答