我试图将NameValuePair的arrylist一个活动传递给另一个活动,我搜索了这么多,我发现了类似的问题但是我无法得到答案,我试过但我得到了例外 ,请有人告诉我如何通过
ArrayList<NameValuePair> namevlaList= new ArrayList<NameValuePair>();
namevlaList.add(new BasicNameValuePair("formal_name",mLegalName));
namevlaList.add(new BasicNameValuePair("device_phone_no",mPhno));
namevlaList.add(new BasicNameValuePair("email",mEmail));
namevlaList.add(new BasicNameValuePair("contact_name",mContactName));
namevlaList.add(new
BasicNameValuePair("contact_number",mContactNumber));
namevlaList.add(new BasicNameValuePair("password",mPwd));
Intent intent = new
Intent(this,Second.class);
intent.putExtra("extra", namevlaList);
startActivity(intent);
答案 0 :(得分:0)
您可以使用Bundle
Intent intent = new Intent(this,Second.class);
Bundle extra = new Bundle();
extra.putSerializable("extra", namevlaList.toArray());// cast to array and put
intent .putExtras(extra);
startActivity(intent);
和第二项活动
Intent i = getIntent();
Bundle extras = i.getExtras();
List<NameValuePair> Namevaluepairvariable = new ArrayList<NameValuePair>();
Namevaluepairvariable = (List<NameValuePair>) extras.getSerializable("extra");
使用implements Serializable
进行第二次活动
答案 1 :(得分:0)