yit*_*al9 64 android bundle parcelable android-intent
为什么捆绑getParcelableArrayList
,getParcelable
方法; 但
Intent
只有putParcelableArrayListExtra
方法?我可以只传输object<T>
,而不是ArrayList
一个元素吗?那么,是getParcelable
为了什么?
yor*_*rkw 152
Intent提供了一堆重载putExtra()方法.
假设您有一个类Foo正确实现Parcelable,将其放入Activity中的Intent:
Intent intent = new Intent(getBaseContext(), NextActivity.class);
Foo foo = new Foo();
intent.putExtra("foo ", foo);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
要从另一个活动中获取它:
Foo foo = getIntent().getExtras().getParcelable("foo");
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助.
归档时间: |
|
查看次数: |
69263 次 |
最近记录: |