为什么要捆绑有getParcelableArrayList,getParcelable方法,但 目的只有方法putParcelableArrayListExtra? 我可以只发送对象< T>,而不是一个元素的ArrayList的? 对于什么呢getParcelable?
Why bundle has getParcelableArrayList, getParcelable methods, but intent has only method putParcelableArrayListExtra ? Can I transmit only object < T > , not ArrayList of one element ? For what then getParcelable ?
意图提供了一堆超载putExtra()的方法。
Intent provides bunch of overloading putExtra() methods.
假设你有一个类Foo实现Parcelable得当,把它变成意图的活动:
Suppose you have a class Foo implements Parcelable properly, to put it into Intent in an Activity:
Intent intent = new Intent(getBaseContext(), NextActivity.class);
Foo foo = new Foo();
intent.putExtra("foo ", foo);
startActivity(intent);
要得到它的意图在另一项活动:
To get it from intent in another activity:
Foo foo = getIntent().getExtras().getParcelable("foo");
希望这有助于。
Hope this helps.