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)