TL;DR: Please use Adapters whenever you need to show lists of data:
http://docs.xamarin.com/guides/android/user_interface/working_with_listviews_and_adapters
Adapters reduce GREF counts by ensuring that you only have GREFs for _visible_
items, not for _every_ item in a list.
On Apr 19, 2013, at 12:29 AM, sridhar <[email protected]> wrote:
> protected void LoadProduct(ProductDetails[] productlist)
How many elements are in `productlist`?
> {
>
> try
> {
>
> LayoutInflater inflater =
> (LayoutInflater)v.Context.GetSystemService(Context.LayoutInflaterService);
> TableLayout tblEvents =
> v.FindViewById<TableLayout>(Resource.Id.tblproducts);
> tblEvents.RemoveAllViews();
Should probably throw a GC.Collect() in here ;-)
> tblEvents.Invalidate();
> tblEvents.RefreshDrawableState();
>
> foreach (ProductDetails events in productlist)
> {
>
>
> using( View item =
> inflater.Inflate(Resource.Layout.searchproductrowtemplate, tblEvents, false)){
This is where things get horribly wrong with GREF counts. We have a GREF for
the view.
>
> TextView lblProductTitle =
> (TextView)item.FindViewById(Resource.Id.lblProductTitle);
> TextView lblCategoryTilte =
> (TextView)item.FindViewById(Resource.Id.lblCategoryTilte);
> TextView lblSupplierTilte =
> (TextView)item.FindViewById(Resource.Id.lblSupplierTilte);
> TextView lblSubstanceTilte =
> (TextView)item.FindViewById(Resource.Id.lblSubstanceTilte);
A GREF for each of these TextViews.
>
> lblProductTitle.Text =
> events.Product;
> lblCategoryTilte.Text =
> events.Category;
> lblSupplierTilte.Text =
> events.SupplierName;
> lblSubstanceTilte.Text =
> events.Substance;
> Button btnProductSelect =
> (Button)item.FindViewById(Resource.Id.btnProductSelect);
This button.
So for _each_ ProductDetail, you have 6 GREFs. If you have ~333 ProductDetails,
you can't run on the emulator.
> can any please guide me to solve this problem.
Please use Adapters. Please.
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid