[mono-android] App Hanging

Tomasz Cielecki tomasz at ostebaronen.dk
Wed Jan 18 10:11:59 UTC 2012


Did it strike you that you might be running out of memory doing this?
You are allocating a whole bunch of Java Objects here. I think it
would be wiser to save the data and lazy load it when you need to
display it.

On Tue, Jan 17, 2012 at 8:17 PM, Fencer04 <fencer04 at gmail.com> wrote:
> I am calling a webservice and getting 729 results in an array. I'm then out
> putting these results in to a 2 column table dynamically. Each time I run it
> chokes somewhere between the 548th and 569th row when setting the text of
> either the 1st or second column like this:
>
> resultView1.Text = outcome.PercentageRatio;
>
> It will also show a window asking if I want to wait while the debugger is
> hung on the expression "Method: Java.Lang.Object.ToString
>
> Nothing is null and the services is returning the data that I expect. Can
> someone help me out. My code is below.
>
>                        int rowCount = 0;
>                        TextView resultView1 = null;
>                        TextView resultView2 = null;
>                        foreach(GeneticOutcomes outcome in results){
>                                TableRow row = new TableRow(this);
>                                row.SetPadding(0, 10, 0, 0);
>                                resultView1 = new TextView(this);
>                                resultView1.SetTextColor(Color.White.ToArgb());
>                                resultView1.SetTextSize(Android.Util.ComplexUnitType.Sp, 16);
>                                //resultView1.LayoutParameters = new
> TableRow.LayoutParams(TableRow.LayoutParams.WrapContent, 20);
>                                resultView1.SetPadding(0, 0, 5, 0);
>                                resultView1.Text = outcome.PercentageRatio;
>                                row.AddView(resultView1);
>                                resultView2 = new TextView(this);
>                                resultView2.SetTextColor(Color.White.ToArgb());
>                                resultView2.SetTextSize(Android.Util.ComplexUnitType.Sp, 16);
>                                float scale = Resources.DisplayMetrics.Density;
>                                int pixels = (int)((325 - resultView1.Width) * scale + 0.5f);
>                                //resultView2.LayoutParameters = new TableRow.LayoutParams(pixels, 20);
>                                resultView2.SetPadding(3,0,40,0);
>                                resultView2.Text = outcome.GeneticString;
>                                row.AddView(resultView2);
>                                resultTable.AddView(row);
>                                rowCount = rowCount + 1;
>                        }
>                        ll.AddView(resultTable);
>
> --
> View this message in context: http://mono-for-android.1047100.n5.nabble.com/App-Hanging-tp5152606p5152606.html
> Sent from the Mono for Android mailing list archive at Nabble.com.
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid



-- 
Med Venlig Hilsen / With Best Regards
Tomasz Cielecki
http://ostebaronen.dk


More information about the Monodroid mailing list