Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get image resource name
    text
    copied!<p>How do I get an imageview resource name which has been set dynamically?</p> <p>This is the image Adapter code:</p> <pre><code> public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return mThumbIds.length; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { View v; if (convertView == null) { // if it's not recycled, initialize some // attributes LayoutInflater li = getLayoutInflater(); v = li.inflate(R.layout.gridxml, null); imageView = (ImageView)v.findViewById(R.id.icon_image); imageView.setLayoutParams(new GridView.LayoutParams(85, 85)); //imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(5, 5, 5, 5); } else { imageView = (ImageView) convertView; } imageView.setImageResource(mThumbIds[position]); imageView.setTag(mThumbIds[position]); System.out.println(mThumbIds[0]); System.out.println(mThumbIds[1]); System.out.println(mThumbIds[2]); System.out.println(mThumbIds[3]); System.out.println(mThumbIds[4]); return imageView; } // references to our images private Integer[] mThumbIds = { R.drawable.directory_xml, R.drawable.news_xml, R.drawable.calendar_xml, R.drawable.facilities_xml, R.drawable.employee_handbook_xml,R.drawable.settings_xml }; } } </code></pre>
 

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