to send from Activity A to Activity B
mCommentbutton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent i2=new Intent(AClass.this,BClass.class);
Bundle b3 = new Bundle();
//usercomments=new ArrayList<UserComments>();
b3.putParcelableArrayList("usercomments", usercomments);
i2.putExtras(b3);
startActivity(i2);
}
});
and BClass.java activity you can parse like this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dialog);
Bundle b = getIntent().getExtras();
usercomments=b.getParcelableArrayList("usercomments");
}
Parsalabel class for UserComments will be like this:
import android.os.Parcel;
import android.os.Parcelable;
public class UserComments implements Parcelable {
public String profileid;
public String userComments;
public String name;
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
// TODO Auto-generated method stub
dest.writeString(profileid);
dest.writeString(userComments);
dest.writeString(name);
}
public static final Parcelable.Creator<UserComments> CREATOR
= new Parcelable.Creator<UserComments>() {
public UserComments createFromParcel(Parcel in) {
return new UserComments(in);
}
public UserComments[] newArray(int size) {
return new UserComments[size];
}
};
public UserComments(Parcel in) {
if(in!=null){
profileid=in.readString();;
userComments=in.readString();
name=in.readString();
}
}
public UserComments() {
}
}
also you can do some thing like this:
Intent i1=new Intent(ProfilesList.this,ProfileInfo.class);
i1.putExtra("profileid", pid);
i1.putExtra("rating",mProfileRatings.get(position));
i1.putExtra("profilename",mProfileNames.get(position));
i1.putExtra("service_charge",serviceList.get(position).service_charge);
i1.putExtra("service_id", serviceList.get(position).service_id);
i1.putExtra("profiledes",mProfileDes.get(position));
i1.putParcelableArrayListExtra("comments", usercomments);
i1.putExtra("country", mProfileCountries.get(position));
i1.putExtra("city", mProfileCities.get(position));
startActivity(i1);
No comments:
Post a Comment