Note that there are some explanatory texts on larger screens.

plurals
  1. POGet the name of the clicked item
    primarykey
    data
    text
    <p>I'm using a class extending BaseAdapter to fill a gridView on my layout. When I click on one of the elements of the gridView I want to get the name of the item I clicked on (where name is name in R.drawable.name)</p> <p>So here's what I wrote</p> <pre><code>gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) { Intent intent = new Intent(ChoseActivity.this, GameActivity.class); String ab = getResources().getResourceEntryName(arg1.getId()); intent.putExtra("AB", ab); startActivity(intent); } } </code></pre> <p>I have this error</p> <pre><code>02-27 13:46:49.285: E/AndroidRuntime(24862): FATAL EXCEPTION: main 02-27 13:46:49.285: E/AndroidRuntime(24862): android.content.res.Resources$NotFoundException: Unable to find resource ID #0xffffffff 02-27 13:46:49.285: E/AndroidRuntime(24862): at android.content.res.Resources.getResourceEntryName(Resources.java:1499) 02-27 13:46:49.285: E/AndroidRuntime(24862): at com.example.kersplatt.ChoseActivity$1.onItemClick(ChoseActivity.java:36) 02-27 13:46:49.285: E/AndroidRuntime(24862): at android.widget.AdapterView.performItemClick(AdapterView.java:284) 02-27 13:46:49.285: E/AndroidRuntime(24862): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812) </code></pre> <p>I don't understand because the image clicked IS in my ressources</p> <p><strong>EDIT1</strong></p> <p>I tried this in getView of my Adapter but still have the same error:</p> <pre><code>ImageView imageView = new ImageView(mContext); imageView.setTag(R.drawable.currentimage); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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