Android发送ArrayList对象

Android发送ArrayList对象,android,android-activity,arraylist,send,Android,Android Activity,Arraylist,Send,我笨手笨脚的 解决我的问题 起源活动 public void marcas(View view) { ArrayList<Localizacion> object = new ArrayList<Localizacion>(localizaciones); Intent intent = new Intent(getApplicationContext(), CompraVenta.class); Bundle args = new Bun

我笨手笨脚的

解决我的问题

起源活动

    public void marcas(View view) {
    ArrayList<Localizacion> object = new ArrayList<Localizacion>(localizaciones);
    Intent intent = new Intent(getApplicationContext(), CompraVenta.class);
    Bundle args = new Bundle();
    args.putSerializable("ARRAYLIST", (Serializable) object);
    intent.putExtra("BUNDLE", args);
    startActivityForResult(intent, RESPUESTA_ACTIVIDAD);
}
public void marcas(视图){
ArrayList对象=新的ArrayList(localizaciones);
Intent Intent=新的Intent(getApplicationContext(),compaventa.class);
Bundle args=新Bundle();
args.putSerializable(“ARRAYLIST”,(Serializable)对象);
意向。额外(“捆绑”,args);
startActivityForResult(意向、响应和行动);
}
命运活动

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_compra_venta);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    Intent intent = getIntent();
    Bundle args = intent.getBundleExtra("BUNDLE");
    ArrayList<Localizacion> object = (ArrayList<Localizacion>) args.getSerializable("ARRAYLIST");
    loc = object;
    enlaceInterfaz();
}
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u compa\u venta);
Toolbar Toolbar=(Toolbar)findViewById(R.id.Toolbar);
设置支持操作栏(工具栏);
Intent=getIntent();
Bundle args=intent.getBundleExtra(“Bundle”);
ArrayList对象=(ArrayList)args.getSerializable(“ArrayList”);
loc=对象;
Enlaceinfaz();
}
在Localizacion班上,我是一个很好的学生。 我的错误是想要像在java类中一样使用数组,而这不是它的工作方式


感谢大家

将您的
设置为
可分组
,然后您将能够将该类对象的列表传递给另一个活动

class Localizacion implements Parceable {

}
现在将数据发送到另一个
活动

intent.putParcelableArrayListExtra("array",object);
在接收端

loc = getIntent().getParcelableArrayExtra("array");

请发布代码,而不是图像…欢迎使用堆栈溢出!请将您的代码作为代码而不是图像发布。您应该将代码段缩进4个空格,以便将它们放入
代码标记中
。使用帖子下方的“编辑”链接编辑问题。