Hallo zusammen,
ich habe ein Problem in folgendem Code:
Java
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Konflikt aufgetreten");
builder.setItems(options, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
// ...
}
});
AlertDialog alert = builder.create();
alert.show();
Wenn das Array options 3 Einträge hat, läuft alles, wie es soll.
Bei nur 2 Einträgen verabschiedet sich das Programm mit folgendem Fehler:
Code
04-10 15:31:32.675: E/AndroidRuntime(511): FATAL EXCEPTION: main
04-10 15:31:32.675: E/AndroidRuntime(511): java.lang.NullPointerException
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.AbsListView.obtainView(AbsListView.java:1409)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.ListView.onMeasure(ListView.java:1127)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.View.measure(View.java:8313)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.View.measure(View.java:8313)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
04-10 15:31:32.675: E/AndroidRuntime(511): at com.android.internal.widget.WeightedLinearLayout.onMeasure(WeightedLinearLayout.java:60)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.View.measure(View.java:8313)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.View.measure(View.java:8313)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.View.measure(View.java:8313)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.os.Handler.dispatchMessage(Handler.java:99)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.os.Looper.loop(Looper.java:123)
04-10 15:31:32.675: E/AndroidRuntime(511): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-10 15:31:32.675: E/AndroidRuntime(511): at java.lang.reflect.Method.invokeNative(Native Method)
04-10 15:31:32.675: E/AndroidRuntime(511): at java.lang.reflect.Method.invoke(Method.java:507)
04-10 15:31:32.675: E/AndroidRuntime(511): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-10 15:31:32.675: E/AndroidRuntime(511): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-10 15:31:32.675: E/AndroidRuntime(511): at dalvik.system.NativeStart.main(Native Method)
Alles anzeigen
Was kann ich tun?