本文介绍了如何通过整数[]使用捆绑在android系统?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

      Integer[] image = { 
       R.drawable.image1,
       R.drawable.image22,

   };

如何使用束通过这个数组?

how can i pass this array using bundle?

推荐答案

使用ArrayList中我们可以发送

by using ArrayList we can send

private ArrayList<Integer> image;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    image = new ArrayList<Integer>();

    image.add(R.drawable.ic_launcher);
    image.add(R.drawable.ic_launcher);

    Button photoButton = (Button) this.findViewById(R.id.button1);
    photoButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {              

            Intent intent = new Intent(PhotoActivity.this,PhotoActivity1.class ); 
            intent.putIntegerArrayListExtra("VALUES", image);               
            startActivity(cameraIntent); 
        }     
    }); 

在接收器类

Intent i = getIntent();
ArrayList<Integer> img = i.getIntegerArrayListExtra("VALUES");

这篇关于如何通过整数[]使用捆绑在android系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 16:19