1. 程式人生 > >fragment之間的傳值

fragment之間的傳值

private String url;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

savedInstanceState = getArguments();

if (savedInstanceState != null) {

url = savedInstanceState.getString("url");

}

}

 

public static MyFragment newInstance(String url) {

Bundle argz = new Bundle();

argz.putString("url", url);

MyFragment fragment = new MyFragment ();

fragment.setArguments(argz);

return fragment;

}