Equivalent of HTML 5 data attributes for android views

Zamurick

New Member
Is there a way I can store/retrieve arbitrary values from a view, similar to HTML5 data attributes?This way, I can have a view call generic \[code\]onClick()\[/code\] methods and the method can retrieve the related data.e.g:\[code\]<ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:onClick="setCountry" android:src="http://stackoverflow.com/questions/12469473/@drawable/ic_flag_germany" /><ImageView android:layout_width="fill_parent" android:layout_height="wrap_content" android:onClick="setCountry" android:src="http://stackoverflow.com/questions/12469473/@drawable/ic_flag_france" />...\[/code\]I would like to be able to retrieve a value from the one that got clicked.\[code\]public void setCountry(View v){ //retrieve data somehow}\[/code\]
 
Back
Top