【发布时间】:2012-03-26 00:25:17
【问题描述】:
我是 android 新手。我需要一些帮助 我有 ArrayList,它是一个实现 Parciable 的对象。我想将此 ArrayList 传递给另一个 Activity。 这是我的 NewsEntity.java
公共类 NewsEntity 实现 Parcelable{ /** * */ 私有位图位图; 私有字符串标题; 私人字符串简介; 私有字符串详细信息; 私人字符串记者; 私有字符串图像文件; 私人字符串日期; 私有字符串读取计数; 私有字符串shareCount; 公共 int addRead_count; public int addShare_count;
private static ByteBuffer dst;
private static byte[] bytesar;
public NewsEntity() {
bitmap=null;
title="";
brief="";
details="";
reporter="";
ImageFile="";
date="";
readCount="";
shareCount="";
addRead_count=0;
addShare_count=0;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public void setBrief(String brief) {
this.brief = brief;
}
public String getBrief() {
return brief;
}
public void setDetails(String details) {
this.details = details;
}
public String getDetails() {
return details;
}
public void setReporter(String reporter) {
this.reporter = reporter;
}
public String getReporter() {
return reporter;
}
public void setImageFile(String imageFile) {
ImageFile = imageFile;
}
public String getImageFile() {
return ImageFile;
}
public void setDate(String date) {
this.date = date;
}
public String getDate() {
return date;
}
public void setReadCount(String readCount) {
this.readCount = readCount;
}
public String getReadCount() {
return readCount;
}
public void setShareCount(String shareCount) {
this.shareCount = shareCount;
}
public String getShareCount() {
return shareCount;
}
public Bitmap getBitmap() {
return bitmap;
}
public void setBitmap(Bitmap bitmap) {
this.bitmap = bitmap;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel out, int flags) {
try{
out.writeString(title);
out.writeString(brief);
out.writeString(details);
out.writeString(reporter);
out.writeString(readCount);
out.writeString(shareCount);
out.writeInt(addRead_count);
out.writeInt(addShare_count);
out.writeString(date);
out.writeString(ImageFile);
}
public static final Parcelable.Creator<NewsEntity> CREATOR = new Parcelable.Creator<NewsEntity>() {
//public class MyCreator implements Parcelable.Creator<MyProduct> {
public NewsEntity createFromParcel(Parcel in) {
return new NewsEntity();
}
public NewsEntity[] newArray(int size) {
return new NewsEntity[size];
}
};
private NewsEntity(Parcel in) {
try{
title=(String) in.readString();
brief=(String) in.readString();
details=(String) in.readString();
date=(String) in.readString();
reporter=(String) in.readString();
readCount=(String) in.readString();
shareCount=(String) in.readString();
ImageFile=(String) in.readString();
addRead_count=(Integer) in.readInt();
addShare_count=(Integer) in.readInt();
bitmap=in.readParcelable(Bitmap.class.getClassLoader());
}
catch(Exception e){}
}
}
以及意图传递 ArrayList 的这一行 newsDetailsIntent.putExtra("display", result_news); startActivity(newsDetailsIntent);
我需要帮助。怎么做
提前致谢
【问题讨论】:
-
这个问题被问了很多次,因为它是在 Activity 之间传递的位图.....自己试试更好
-
我已经阅读了很多文章,但仍然无法拥有它。我会再试一次。谢谢 samir
-
所有文章都在讨论如何在意图中传递位图对象本身。但我打算将对象作为全部传递。我认为它不一样
标签: android