我已经Bundle
在几个 Android 回调方法中看到了 s 的恢复,但在许多情况下,在开发者Bundle
网站上手动创建和设置s ,在这种情况下来自创建时的外部消息:Fragment
public static DetailsFragment newInstance(int index) {
DetailsFragment f = new DetailsFragment();
// Supply index input as an argument.
Bundle args = new Bundle();
args.putInt("index", index);
f.setArguments(args);
return f;
}
例如,在 this other question中,在方法中恢复了捆绑数据onCreateView()
。
public class Frag2 extends Fragment {
public View onCreateView(LayoutInflater inflater,
ViewGroup containerObject,
Bundle savedInstanceState){
//here is your arguments
Bundle bundle=getArguments();
//here is your list array
String[] myStrings=bundle.getStringArray("elist");
}
}
我对Bundle
每个回调方法与“其他包”提供的数据有点困惑:
Bundle bundle=getArguments();
以及检索这些不同类型的捆绑数据的正确方法和位置。
提前致谢!