Thanks in advance,I am trying to pass the values from one activity to another.
Most of my code works however when user clicks the listview image I want to display that image in another activity.
Activity A Here I am trying to pass the current clicked image
mSelfieAdapter = new SelfieImageAdapter(this,
R.layout.selfie_list,
imageArry);
ListView dataList = (ListView) findViewById(R.id.list);
dataList.setAdapter(mSelfieAdapter);
// up to here the listview is displayed for the user.
dataList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
List<SelfieImage> selfs = db.getAllSelfies();
Intent i = new Intent(DailySelfieActivity.this, Camera.class);
// Pass all data flag
i.putExtra("image",imageInByte );
System.out.println(imageInByte);
// Pass a single position
i.putExtra("position", position);
// Open SingleItemView.java Activity
startActivity(i);
}
});
Activity B Here I am trying to display the image in full size.
public class Camera extends Activity {
byte imageInByte[];
ImageView imgflag;
int position;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.singleitemview);
Intent i = getIntent();
position = i.getExtras().getInt("position");
imageInByte = i.getByteArrayExtra("image");
System.out.println(imageInByte);
imgflag = (ImageView) findViewById(R.id.flag);
imgflag.setImageResource(imageInByte[position]);
}
}
**I have resolved the above issues by changing the above code to: **