Thursday, April 5, 2012

[android-developers] Find Image Resource Id From Image View

I have a screen full of image views, and depending on which one is clicked, it opens a second activity passing the values.
I.E.:

<ImageView
                    android:id="@+id/img01"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentTop="true"
                    android:onClick="gridClick"
                    android:padding="1px"
                    android:src="@drawable/geo_cell_01" />

                <ImageView
                    android:id="@+id/img02"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_toRightOf="@id/img01"
                    android:onClick="gridClick"
                    android:padding="1px"
                    android:src="@drawable/geo_cell_02" />

Java Code:

public void gridClick(View v) {

Intent gridInfo = new Intent(Master.this, GridInfo.class);
ImageView img = (ImageView)findViewById(v.getId());
//Here is my problem
startActivity(gridInfo);

}


I now have the ImageView assigned to a variable, but the value I need to pass to the second activity is the R.id.xxx of the drawable inside of the image view..
How would I go about getting this ID?
Thanks
~Matt

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate