两个Activity之间传list值

序列化bean为了两个Activity之间list传值
package com.zdy.edu.help;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 获取通知通讯录分组工具类 序列化为了两个Activity之间list传值
 * @author admin
 *
 */
public class NoticeAddress implements Parcelable {

	private String id;
	//分组名
	private String groupName;
	//用户数
	private String userCount;
	//分组类型 Cls 班级分组 Dep 部门分组
	private String groupType;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getGroupName() {
		return groupName;
	}
	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
	public String getUserCount() {
		return userCount;
	}
	public void setUserCount(String userCount) {
		this.userCount = userCount;
	}
	public String getGroupType() {
		return groupType;
	}
	public void setGroupType(String groupType) {
		this.groupType = groupType;
	}
	public NoticeAddress(String id, String groupName, String userCount,
			String groupType) {
		super();
		this.id = id;
		this.groupName = groupName;
		this.userCount = userCount;
		this.groupType = groupType;
	}
	public NoticeAddress() {
		super();
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(this.id);
		dest.writeString(this.groupName);
		dest.writeString(this.userCount);
		dest.writeString(this.groupType);
	}

	protected NoticeAddress(Parcel in) {
		this.id = in.readString();
		this.groupName = in.readString();
		this.userCount = in.readString();
		this.groupType = in.readString();
	}

	public static final Creator<NoticeAddress> CREATOR = new Creator<NoticeAddress>() {
		@Override
		public NoticeAddress createFromParcel(Parcel source) {
			return new NoticeAddress(source);
		}

		@Override
		public NoticeAddress[] newArray(int size) {
			return new NoticeAddress[size];
		}
	};
}

activity1__activity2__activity1

</pre><pre name="code" class="java"><span style="white-space:pre">		</span>    ArrayList<NoticeAddress> lis = classAdapter.getList();
                    NoticeAddress[] array = new NoticeAddress[lis.size()];
                    lis.toArray(array);
                    Intent intent = new Intent();
                    intent.putExtra("sendList", array);
                    setResult(RESULT_OK, intent);
                    finish();

<pre name="code" class="html">protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (requestCode==REQUEST_CODE) {
			if (resultCode == RESULT_OK) {
				Parcelable[] receivedList = data.getParcelableArrayExtra("sendList");
				for (int i = 0; i < receivedList.length; i++) {
					System.out.println("~~~~~~[" + i + "]:" + ((NoticeAddress) receivedList[i]).getGroupName());
				}
			}
		}
	}


</pre>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值