Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8602897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:11:57+00:00 2026-06-12T02:11:57+00:00

I am trying to get the image property when there is an onclick event

  • 0

I am trying to get the image property when there is an onclick event happens on the images displayed in the Grid View inside a Fragment. I am trying to fetch values from the parameters passed to onItemClick method. When I try to access any parameter, inside the toaster the app stops working.

Inside the toaster I am replacing the text “test” with v.getId()/position/id. Then the app stops.

Here is the code.

    GridView gridView = (GridView) view.findViewById(R.id.imageGrid);
    gridView.setAdapter(new ImageAdapter(this));    
    gridView.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
         Toast.makeText(getActivity(), "test"  ,Toast.LENGTH_SHORT).show();
        }});

Do I need to provide any other details? or am I making any silly mistakes?

Update:
I am adding my error log here.

09-28 16:03:53.327: W/dalvikvm(15316): threadid=1: thread exiting with uncaught exception (group=0x410f6300)
09-28 16:03:53.337: E/AndroidRuntime(15316): FATAL EXCEPTION: main
09-28 16:03:53.337: E/AndroidRuntime(15316): android.content.res.Resources$NotFoundException: String resource ID #0x10
09-28 16:03:53.337: E/AndroidRuntime(15316):    at android.content.res.Resources.getText(Resources.java:229)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at android.widget.Toast.makeText(Toast.java:265)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at com.example.store.fragments.AllStoresFragment$1.onItemClick(AllStoresFragment.java:111)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at android.widget.AdapterView.performItemClick(AdapterView.java:298)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at android.widget.AbsListView.performItemClick(AbsListView.java:1086)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:2855)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at android.widget.AbsListView$1.run(AbsListView.java:3529)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at android.os.Handler.handleCallback(Handler.java:615)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at android.os.Handler.dispatchMessage(Handler.java:92)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at android.os.Looper.loop(Looper.java:137)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at android.app.ActivityThread.main(ActivityThread.java:4745)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at java.lang.reflect.Method.invokeNative(Native Method)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at java.lang.reflect.Method.invoke(Method.java:511)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-28 16:03:53.337: E/AndroidRuntime(15316):    at dalvik.system.NativeStart.main(Native Method)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:11:58+00:00Added an answer on June 12, 2026 at 2:11 am

    If you pass v.getId()/position/id to the Toast it will think that it represents the id of a String resources from strings.xml, which it will not find and throw that exception. Try this instead:

    Toast.makeText(getActivity(), String.valueOf(position), Toast.LENGTH_SHORT).show();
    

    or

    Toast.makeText(getActivity(), "" + position + " " + id, Toast.LENGTH_SHORT).show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the image.size.h and image.size.w of the UIImage inside of an
Im trying to get an image from a wcf rest service like so: [ServiceContract]
I'm trying to get an image sitting at a URL that is protected by
I'm trying to get an image off the internet from an URL in java.
I'm trying to get an image from URL and save it to the isolated
I am trying to get an image from URL in Android and set it
I am trying to get an image from an HTTP server using Perl. I
I am trying to get an image to display on a page using a
Trying to get my arrow image to stick to the right of the anchor
I've been trying to get an Gtk2::Image object in this Perl Gtk2 application to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.