Intent 传递数据,可以传递简单的字串,数字。还可以传递数组。
发送方Activity:
- private String [] pose_title = null; //发送方数组
private String [] pose_title = null; //发送方数组
- pose_title = new String[100];
pose_title = new String[100];
- Intent intent = new Intent();
- intent.putExtra("pose_name", pose_name);
- intent.putExtra("img_file_name", img_file_name);
- Bundle b=new Bundle();
- b.putStringArray("pose_title", pose_title);
- intent.putExtras(b);
- intent.setClass(SexPosition.this, ShowDetailPose.class);
- SexPosition.this.startActivity(intent);
Intent intent = new Intent();
intent.putExtra("pose_name", pose_name);
intent.putExtra("img_file_name", img_file_name);
Bundle b=new Bundle();
b.putStringArray("pose_title", pose_title);
intent.putExtras(b);
intent.setClass(SexPosition.this, ShowDetailPose.class);
SexPosition.this.startActivity(intent);
接收方Activity:
- private String [] pose_title = null; //接收方数组
private String [] pose_title = null; //接收方数组
- Intent intent = getIntent();
- String pose_name = intent.getStringExtra("pose_name");
- String img_file_name = intent.getStringExtra("img_file_name");
- Bundle b=this.getIntent().getExtras();
- pose_title = b.getStringArray("pose_title");