java.lang.reflect.invocationtargetexception在android系统

编程入门 行业动态 更新时间:2024-10-24 23:28:46
本文介绍了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系统

本文发布于:2023-10-28 23:37:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538098.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:系统   lang   java   reflect   android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!