Question

I'm making an app and i need to send data from an activity to another. I can send data from the associated class to each row but i cant send the image correctly. I'm always sending the same one

I've implemented a custom ListView, this is the 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 the OnClickListener, i'm getting all data except from the Image (Always sendig the top one visible)

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());

            imageView.buildDrawingCache();
            Bitmap bmp = imageView.getDrawingCache();
            informacion.putParcelable("bmp", bmp);                              
        }

    });

how can i get the Image from the clicked row?

Was it helpful?

Solution

use this way

lv = (ListView) findViewById(R.id.lista);       
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> a, View v, int position, long id) {
            // get the Image from the clicked row

          ImageView image = (ImageView)v.findViewByID(R.id.imageId);

        ......                   
        }

    });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top