Android Gridview onclick Event正在提供致命异常

时间:2014-06-02 10:11:37

标签: java android gridview

我有一个gridView,它正在填充图像文本等,现在我只想让所有gridview可点击 所以我试着制作它

gridView1.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View view,
                        int position, long id) {
                    Log.i("The clicked item is:"+position, null);

                }

            });

但是当我单击gridview而不是向我显示logcat中的位置时,网格视图不起作用,它会将其视为致命异常。

06-02 05:52:49.887: W/dalvikvm(3085): threadid=1: thread exiting with uncaught exception (group=0xb4a9aba8)
06-02 05:52:49.977: E/AndroidRuntime(3085): FATAL EXCEPTION: main
06-02 05:52:49.977: E/AndroidRuntime(3085): Process: com.coded.sandeep, PID: 3085
06-02 05:52:49.977: E/AndroidRuntime(3085): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.IllegalStateException: Unable to get package info for com.coded.sandeep; is package not installed?
06-02 05:52:49.977: E/AndroidRuntime(3085):     at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
06-02 05:52:49.977: E/AndroidRuntime(3085):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4317)
06-02 05:52:49.977: E/AndroidRuntime(3085):     at android.app.ActivityThread.access$1500(ActivityThread.java:135)
06-02 05:52:49.977: E/AndroidRuntime(3085):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
06-02 05:52:49.977: E/AndroidRuntime(3085):     at android.os.Handler.dispatchMessage(Handler.java:102)

2 个答案:

答案 0 :(得分:0)

您无法在Log.i()中将null作为参数传递。传递两个有效的字符串参数。

类似于:Log.i("Clicked Position is : ", Integer.toString(position));

答案 1 :(得分:0)

应该更多的是

Log.i(getClass().getSimpleName(), "The clicked item is at: " + position);

因此标签和消息不是混合的blob。