Note that there are some explanatory texts on larger screens.

plurals
  1. POCant get ImageView onItemClick from custom ListView Android [EDIT]
    primarykey
    data
    text
    <p>I've implemented a custom ListView, this is the structure of each row:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" &gt; &lt;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" /&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="left" android:padding="10dp" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/titulo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="17sp" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;TextView android:id="@+id/sitio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="12sp" android:textAppearance="?android:attr/textAppearanceSmall" /&gt; &lt;TextView android:id="@+id/fecha" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="12sp" android:textAppearance="?android:attr/textAppearanceSmall" /&gt; &lt;/LinearLayout&gt; </code></pre> <p></p> <p>I've setted to my ListView and adapter and it works fine while accesing data, but when i try to convert an ImageView to a byteArray so i can send it to another Activitie, i can't get the ImageView</p> <pre><code>lv = (ListView) findViewById(R.id.lista); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; 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); } }); </code></pre> <p>I'm getting my bmp NULL:</p> <pre><code>Bitmap bmp = BitmapFactory.decodeResource(a.getResources(), R.id.imagenEvento); </code></pre> <p>I guess i should indicate the position of the item due it's in a ListView but i don't know how to do it</p> <p>[EDIT] The problem is solved, i'm getting the image in the next Activity, but, i'm getting always the top image from the ListView of this Activity, how can i get the clicked Image?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload