我编写了一个打开复选框多项目对话框的函数,我从按钮调用此函数。应用程序在启动时崩溃。
我的对话框功能如下:
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();
}
我从一个图像按钮调用这个函数,如下所示:
mGLView.showlist(this);
我的logcat如下:
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
而且我还想知道列表中的项目数是否超过然后滚动会出现?