4

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

Actually this is part of xml that define customize alert-dialog. I want that when I click on first ImageView(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")

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?

8
  • What is line 428 MainaScreen.java? Commented Jan 9, 2014 at 11:31
  • "Caused by: java.lang.NullPointerException at com.example.demoekot.MainScreen.clickHandler(MainScreen.java:428)" - there's something null being dereferenced on line 428. Commented Jan 9, 2014 at 11:31
  • My line no 428 is :- img_v_save_change_order_var.setVisibility(ImageView.VISIBLE); Commented Jan 9, 2014 at 11:33
  • @PriyaSingh img_v_save_change_order_var is null. post the code where you initialize. Commented Jan 9, 2014 at 11:36
  • @Raghunandan.. I initialize it onCreate() block as follow img_v_save_change_order_var = (ImageView)findViewById(R.id.save_change_order_id); Commented Jan 9, 2014 at 11:39

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

you using that xml coding for custom alert dialog means how can you call from main xml? have you called above xml class anywhere?

refer below link

http://www.mkyong.com/android/android-custom-dialog-example/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.