android java target=1.6,android中的java.lang.reflect.invocationtargetexception

我遇到了问题,我的xml文件如下

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" />

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" />

实际上这是定义自定义alert-dialog的xml的一部分.我希望当我点击第一个ImageView(android:id =“@ id / edt_order”)时,它的可见性变为Invisible而代替这个ImageView setvisible另一个ImageView(android:id =“@ id / save_change_order_id”)

为此,我在java文件中写下以下代码:

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();

}

}

}

但我得到的例外情况如下:

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

为什么我得到这个例外?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值