Hello
I'm trying to display 2 AlertDialog depending on what the user choose in the
2st one.
But ... I've this error:
10-23 12:38:00.539 I/ActivityManager( 5575): Starting activity: Intent {
act=android.intent.action.MAIN flg=0x10100000
cmp=net.colsup.homidroid/homidroid.activities.Login }
10-23 12:38:02.549 E/AndroidRuntime( 8334): FATAL EXCEPTION: main
10-23 12:38:02.549 E/AndroidRuntime( 8334):
java.lang.ArrayIndexOutOfBoundsException
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
com.android.internal.app.AlertController$AlertParams$1.getView(AlertController.java:816)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.AbsListView.obtainView(AbsListView.java:1315)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.ListView.measureHeightOfChildren(ListView.java:1198)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.ListView.onMeasure(ListView.java:1109)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.View.measure(View.java:8172)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.View.measure(View.java:8172)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
com.android.internal.widget.WeightedLinearLayout.onMeasure(WeightedLinearLayout.java:60)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.View.measure(View.java:8172)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.View.measure(View.java:8172)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3140)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.View.measure(View.java:8172)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.ViewRoot.performTraversals(ViewRoot.java:805)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.view.ViewRoot.handleMessage(ViewRoot.java:1744)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.os.Handler.dispatchMessage(Handler.java:99)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.os.Looper.loop(Looper.java:144)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
android.app.ActivityThread.main(ActivityThread.java:4937)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
java.lang.reflect.Method.invokeNative(Native Method)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
java.lang.reflect.Method.invoke(Method.java:521)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-23 12:38:02.549 E/AndroidRuntime( 8334): at
dalvik.system.NativeStart.main(Native Method)
10-23 12:38:02.569 W/ActivityManager( 5575): Force finishing activity
net.colsup.homidroid/homidroid.activities.Login
The error happend when the second AlertDialog is show
private void showPreferencePopup()
{
this.currentPreferences = this.getPreferences();
if (this.currentPreferences.Count == 0)
return; // not yet any items
string[] items = this.currentPreferences.Select(p =>
p.Server).ToArray();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetTitle("Choix du serveur");
builder.SetPositiveButton("Ajouter", delegate(object
sender, DialogClickEventArgs e)
{
// Let the popup close and show the normal login form
this.popupDeletePref = false;
this.popupPref = false;
});
builder.SetNegativeButton("Supprimer", delegate(object
sender, DialogClickEventArgs e)
{// Open the delete alert dialog
this.popupDeletePref = true;
this.popupPref = false;
});
builder.SetItems(items, delegate(object sender,
DialogClickEventArgs e)
{// connect to selected server
(..)
});
var alert = builder.Create();
alert.DismissEvent += new EventHandler(alert_DismissEvent);
alert.Show();
}
private void showDeletePreferencesPopup()
{
this.currentPreferences = this.getPreferences();
string[] items = this.currentPreferences.Select(p =>
p.Server).ToArray();
List<int> selected = new List<int>();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.SetTitle("Supprimer des connexions");
builder.SetPositiveButton("Annuler", delegate(object
sender, DialogClickEventArgs e)
{// Return to the 1st dialog
this.popupPref = true;
this.popupDeletePref = false;
});
builder.SetNegativeButton("Supprimer la selection",
delegate(object sender, DialogClickEventArgs e)
{// Delete selected entries, and return to the 1st dialog
(...)
this.popupPref = true;
this.popupDeletePref = false;
});
builder.SetMultiChoiceItems(items, new bool[] { },
delegate(object sender, DialogMultiChoiceClickEventArgs e)
{// Add or Remove clicked item from the list of items to delete
(...)
});
var alert = builder.Create();
alert.DismissEvent += new EventHandler(alert_DismissEvent);
alert.Show();
}
void alert_DismissEvent(object sender, EventArgs e)
{// Check which dialog must be shown
if (this.popupPref)
this.showPreferencePopup();
else if (this.popupDeletePref)
this.showDeletePreferencesPopup(); }
The showPreferencePopup is called from the OnCreate, and show the first
dialog.
The first dialog show a list of server (stored as preferences) and two
buttons. If the user click on the delete button, I show the second dialog
(by calling the showDeletePreferencesDialog) that let him choose which
entry to delete
I've put in red the line where it crash
I've also tried to open the second dialog from the click event, but it's the
same behavior.
There is no error message in Visual Studio. The device only say that the
application has closed unexpectedly
Any idea ? Or any other way to do that ? As I'm new to android dev, I
suppose I'm doing something wrong but I don't see what.
Thanks a lot for your help,
Fabrice
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid