I have an issue which I cannot solve at this point, this issue might be very simple to some of you but I’m really can not proceed further. I’m temporarily storing objects from database in an array List and I can display these objects in my app as list view. However I need to pass just the Item clicked to another activity. I have tried to pass this as follows.
ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> parent,
View view,int position, long id) {
// TODO Auto-generated method stub
Intent in = new Intent(getApplicationContext(),
Property.class);
in.putExtra("temp_image", image);
in.putExtra("temp_identifier", identif);
in.putExtra("temp_bedrooms", bedrooms);
in.putExtra("temp_address", address);
in.putExtra("temp_propType", propType);
startActivity(in);
}});
And receiving from the other Activity
identif = getIntent().getExtras().getStringArrayList("temp_identifier");
bedrooms = getIntent().getExtras().getStringArrayList("temp_bedrooms");
address = getIntent().getExtras().getStringArrayList("temp_address");
propType = getIntent().getExtras().getStringArrayList("temp_propType");
image = getIntent().getExtras().getParcelable("temp_image");
img = (ImageView) view.findViewById(R.id.image);
img.setImageBitmap(BitmapFactory.decodeByteArray(
image.get(POSITION), 0,
image.get(POSITION).length));
Doing the above has two downfalls.
1) Returns a an Array List objects(Text only)
2) I cannot pass the Image
How do I show just the clicked Array List Item and display it in another activity.
Edited Version:strong text
**Here is how i'm querying the images!**
private void getDataAndPopulate() {
// TODO Auto-generated method stub
image = new ArrayList<byte[]>();
identif = new ArrayList<String>();
price= new ArrayList<String>();
bedrooms= new ArrayList<String>();
address= new ArrayList<String>();
propType= new ArrayList<String>();
Cursor cursor = getEvents(" gall,properties where properties._id =
gall._id " );
//Select* from gall,properties where properties.propertyId = gall.GallId
while (cursor.moveToNext()) {
String temp_id = cursor.getString(0);
byte[] temp_image = cursor.getBlob(2);
String temp_identifier = cursor.getString(1);
String temp_price = cursor.getString(3);
String temp_bedrooms = cursor.getString(4);
String temp_address = cursor.getString(5);
String temp_propType = cursor.getString(6);
image.add(temp_image);
identif.add(temp_identifier);
price.add(temp_price);
bedrooms.add(temp_bedrooms);
address.add(temp_address);
propType.add(temp_propType);
}
and the getDataAndPopulate() is
private Cursor getEvents(String table) {
SQLiteDatabase db = (placeData).getReadableDatabase();
Cursor cursor = db.query(table, null, null, null, null, null, null);
return cursor;
}
Here i'm asing them to adapter.
String[] identifierArray = (String[]) identif.toArray(new String[identif
.size()]);
ItemsAdapter itemsAdapter = new ItemsAdapter(Result.this,
R.layout.item, identifierArray);
setListAdapter(itemsAdapter);
Thanks in advance