
class A extends Activity{ private class myClass{ } myClass obj = new myClass(); intent i = new Intent(); Bundle b = new Bundle(); b.putParcelable(Constants.Settings,obj); //I get the error The method putParcelable(String,Parcelable) in the type Bundle is not applicable for the arguments (int,A.myClass) i.setClass(getApplicationContext(),B.class); startActivity(i); } 解决方法 正如错误所暗示的,你需要让你的类(在这种情况下是myClass)实现 Parcelable.如果你看一下 documentation for Bundle,所有putParcelable方法都采用Parcelable或它们的某种形式的集合. (这是有意义的,给定名称.)因此,如果您想使用该方法,您需要将Parcelable实例放入包中… 当然你不必使用putParcelable – 你可以改为实现Serializable并调用putSerializable.
总结以上是内存溢出为你收集整理的使用Parcelable将对象从一个android活动传递到另一个全部内容,希望文章能够帮你解决使用Parcelable将对象从一个android活动传递到另一个所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)