user2598157
user2598157

Reputation:

Checkbox multi item dialog not working

I have written a function that opens checkbox multiitems dialogs i call this function from a button. The application crashes when it is launched.

My function for dialog is as follws:

 public void showlist(Context c)
    {
        final CharSequence[] layers_name=null;//=new CharSequence[];

        for (int i=0;i<m_Renderer.m_Project.m_Layers.size();i++)
        {
            layers_name[i]=m_Renderer.m_Project.m_Layers.get(i).m_LayerName;

        }


        this.m_listview=new AlertDialog.Builder(c);
        m_listview.setTitle("Layers Information").setMultiChoiceItems(layers_name,null,new DialogInterface.OnMultiChoiceClickListener()
        {
            @Override
        public void onClick(DialogInterface dialog,int which,boolean ischecked)
            {
                if (ischecked)
                {}
                else
                {}

            }

        }


        ).setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

            }
        }


        );
        m_listview.show();

    }

I call this function from an image button which is as follows:

mGLView.showlist(this);

My logcat is as follows:

java.lang.IllegalStateException: Could not execute method of the activity
        at android.view.View$1.onClick(View.java:3691)
        at android.view.View.performClick(View.java:4211)
        at android.view.View$PerformClick.run(View.java:17267)
        at android.os.Handler.handleCallback(Handler.java:615)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4898)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at android.view.View$1.onClick(View.java:3686)
        ... 11 more
        Caused by: java.lang.NullPointerException
        at idtech.ESDN.GraphicsView.showlist(Map.java:229)
        at idtech.ESDN.Map.bt_open_layers(Map.java:137)
        ... 14 more

And i also wanted to know if number of items in list exceeds then scroll will come or not?

Upvotes: 0

Views: 101

Answers (1)

user2598157
user2598157

Reputation:

Issue resolved. The app was crashing because layers_name was initialised to null. When i initialised it then it was working fine.

Upvotes: 1

Related Questions