java.lang.reflect.invocationtargetexception在android系统 [英] java.lang.reflect.invocationtargetexception in android

查看:906
本文介绍了java.lang.reflect.invocationtargetexception在android系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个问题,我的XML文件如下

I am getting a problem , my xml file is as follow

       <ImageView
    android:id="@+id/edt_order"
    android:layout_width="50dp"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/separator_bottom"
    android:background="#fff"
    android:clickable="true"
    android:onClick="clickHandler"
    android:src="@drawable/edit_button" />
        <ImageView
    android:id="@+id/save_change_order_id"
    android:layout_width="100dp"
    android:layout_height="match_parent"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/separator_bottom"
    android:background="#fff"
    android:clickable="true"
    android:visibility="gone"
    android:onClick="clickHandler"
    android:src="@drawable/save_button" />

其实这是XML定义自定义警报的对话的一部分。我想,当我第一次图像视图点击(机器人:ID =@ + ID / edt_order),那么它的知名度成为隐形,并在地方这个ImageView的调用setVisible一个又一个的ImageView(机器人的:ID =@ + ID / save_change_order_id)

Actually this is part of xml that define customize alert-dialog. I want that when i click on first Image-view( android:id="@+id/edt_order" ) , then its visibility become "Invisible" and in place of this ImageView setvisible a another ImageView ( android:id="@+id/save_change_order_id" )

为此,我写下低于code中的Java文件

For this i write down below code in java file

         public void clickHandler(View v) {

    if (v.getId() == R.id.edt_order) {                                  
        System.out.println(" edit buton click");                    
        System.out.println("Click my Order");
        img_v_save_change_order_var.setVisibility(ImageView.VISIBLE);
        img_btn_edit_order_var.setVisibility(ImageView.INVISIBLE);
            int jcount = 0;   
        // save_change_order_id   
        jcount = countjournals();             
        System.out.println("jcount = " + jcount);              


        if (jcount < 1) {             
            alertShow();   
        } else {
            intiliazeOrderListDialog();                           

                        }
        }               
    }

但我得到一个例外如下 -

But i am getting a exception as follow-

         01-09 06:12:14.550: D/AndroidRuntime(1981): Shutting down VM
                 01-09 06:12:14.550: W/dalvikvm(1981): threadid=1: thread exiting with uncaught exception (group=0xb3ab3b90)
                 01-09 06:12:14.730: E/AndroidRuntime(1981): FATAL EXCEPTION: main
                01-09 06:12:14.730: E/AndroidRuntime(1981): Process: com.example.demoekot, PID: 1981
                01-09 06:12:14.730: E/AndroidRuntime(1981): java.lang.IllegalStateException: Could not execute method of the activity
                01-09 06:12:14.730: E/AndroidRuntime(1981):     at android.view.View$1.onClick(View.java:3814)
                01-09 06:12:14.730: E/AndroidRuntime(1981):     at android.view.View.performClick(View.java:4424)
                01-09 06:12:14.730: E/AndroidRuntime(1981):     at android.view.View$PerformClick.run(View.java:18383)
              01-09 06:12:14.730: E/AndroidRuntime(1981):   at android.os.Handler.handleCallback(Handler.java:733)
             01-09 06:12:14.730: E/AndroidRuntime(1981):    at android.os.Handler.dispatchMessage(Handler.java:95)
           01-09 06:12:14.730: E/AndroidRuntime(1981):  at android.os.Looper.loop(Looper.java:137)
           01-09 06:12:14.730: E/AndroidRuntime(1981):  at android.app.ActivityThread.main(ActivityThread.java:4998)
         01-09 06:12:14.730: E/AndroidRuntime(1981):    at java.lang.reflect.Method.invokeNative(Native Method)
           01-09 06:12:14.730: E/AndroidRuntime(1981):  at java.lang.reflect.Method.invoke(Method.java:515)
         01-09 06:12:14.730: E/AndroidRuntime(1981):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
        01-09 06:12:14.730: E/AndroidRuntime(1981):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
        01-09 06:12:14.730: E/AndroidRuntime(1981):     at dalvik.system.NativeStart.main(Native Method)
        01-09 06:12:14.730: E/AndroidRuntime(1981): Caused by: java.lang.reflect.InvocationTargetException

               01-09 06:12:14.730: E/AndroidRuntime(1981):  at java.lang.reflect.Method.invokeNative(Native Method)
              01-09 06:12:14.730: E/AndroidRuntime(1981):   at java.lang.reflect.Method.invoke(Method.java:515)
             01-09 06:12:14.730: E/AndroidRuntime(1981):    at android.view.View$1.onClick(View.java:3809)
            01-09 06:12:14.730: E/AndroidRuntime(1981):     ... 11 more
            01-09 06:12:14.730: E/AndroidRuntime(1981): Caused by: java.lang.NullPointerException
            01-09 06:12:14.730: E/AndroidRuntime(1981):     at com.example.demoekot.MainScreen.clickHandler(MainScreen.java:428)
           01-09 06:12:14.730: E/AndroidRuntime(1981):  ... 14 more

为什么我收到此异常,我没有得到什么?在此先感谢所有。

Why i am getting this exception i didn't get ? Thanks in advance to all.

推荐答案

我认为这是在你的主类图像声明的问题。

I think it is problem of declaration of image in your main class.

这篇关于java.lang.reflect.invocationtargetexception在android系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆