Cant get ImageView onItemClick from custom ListView Android [EDIT] -


i've implemented custom listview, structure of each row:

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" >  <imageview android:id="@+id/imagenevento" android:layout_width="80dp" android:layout_height="80dp" android:scaletype="centercrop" android:adjustviewbounds="false" android:paddingbottom="2dp"      android:contentdescription="@string/contenidoimagen"        />  <linearlayout     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:gravity="left"     android:padding="10dp"     android:orientation="vertical" >      <textview         android:id="@+id/titulo"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="17sp"         android:textappearance="?android:attr/textappearancelarge" />      <textview         android:id="@+id/sitio"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="12sp"         android:textappearance="?android:attr/textappearancesmall" />      <textview         android:id="@+id/fecha"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textsize="12sp"         android:textappearance="?android:attr/textappearancesmall" />  </linearlayout> 

i've setted listview , adapter , works fine while accesing data, when try convert imageview bytearray can send activitie, can't imageview

lv = (listview) findviewbyid(r.id.lista);            lv.setonitemclicklistener(new onitemclicklistener() {          @override         public void onitemclick(adapterview<?> a, view v, int position, long id) {             //creo el nuevo objeto para poder llamarlo             intent intent = new intent(allproductsactivity.this, postactivity.class);              //creo la informacion para pasar entre actividades             bundle informacion= new bundle();             informacion.putint("id", eventos.get(position).getid());              bitmap bmp = bitmapfactory.decoderesource(a.getresources(), r.id.imagenevento);             bytearrayoutputstream stream = new bytearrayoutputstream();             bmp.compress(bitmap.compressformat.png, 100, stream);             byte[] bytearray = stream.tobytearray();             informacion.putbytearray("imagen", bytearray);                                       }      }); 

i'm getting bmp null:

bitmap bmp = bitmapfactory.decoderesource(a.getresources(), r.id.imagenevento); 

i guess should indicate position of item due it's in listview don't know how it

[edit] problem solved, i'm getting image in next activity, but, i'm getting top image listview of activity, how can clicked image?

the imageview using reference no need convert array pass reference directly static or make static class holds such references can use later, can save image of imageview bitmap , encode save image byte array , decode when needed, , later use imageview imageview.setimagebitmap(bitmap);

imageview.builddrawingcache(); bitmap bmap = imageview.getdrawingcache();   public string bitmaptostring(bitmap bitmap){     bytearrayoutputstream baos = new bytearrayoutputstream();     bitmap.compress(bitmap.compressformat.jpeg,100,baos);     byte[] b = baos.tobytearray();     string image = base64.encodetostring(b, base64.default);     return image; }   public bitmap stringtobitmap(string image){     byte[] encodebyte =  base64.decode(image, base64.default);     bitmap bitmap = bitmapfactory.decodebytearray(encodebyte, 0 , encodebyte.length);     return bitmap; } 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -