由网友(一个人挺好)分享简介:如何一些数据转移到另一个片段也有人用演员做了意图?How to transfer some data to another Fragment likewise it was done with extras for intents?推荐答案使用一个Bundle。这里有一个例子:Use a Bundle. Her...
如何一些数据转移到另一个片段
也有人用演员
做了意图
?
How to transfer some data to another Fragment
likewise it was done with extras
for intents
?
推荐答案
使用一个Bundle。这里有一个例子:
Use a Bundle. Here's an example:
Fragment fragment = new Fragment();
Bundle bundle = new Bundle();
bundle.putInt(key, value);
fragment.setArguments(bundle);
捆绑已经把方法的大量数据类型。请参阅http://developer.android.com/reference/android/os/Bundle.html
然后在你的片段,检索数据(例如,在的onCreate())有:
Then in your Fragment, retrieve the data (e.g. in onCreate()) with:
Bundle bundle = this.getArguments();
int myInt = bundle.getInt(key, defaultValue);
相关推荐
最新文章