0

pagerView の操作が必要です。100 ページ後にページビューを使用すると、アプリケーションで「メモリ不足」というエラーが表示されます。ビューを破棄する方法が必要です。これは、最初から最後まですべてをメモリに保持するためです。ビューで、私が作成した 4 つのボックスをイメージ (変更されません) と 2 つのボタンで記憶します。

これは私のアダプターです:

namespace ProvaViewPager
{
    public class FragmentAdapter : FragmentStatePagerAdapter
    {
        int mCount;
        private FragmentManager mFragmentManager;

        public FragmentAdapter (FragmentManager fm) : base (fm)
        {
            mCount = 200;
            mFragmentManager = fm;
        }

        public override Fragment GetItem (int position)
        {
            return new SwiftView (position);
        }

        public override int Count {
            get {
                return mCount;  
            }   
        }

distroy メソッドを使用しますか? しかし、どのように?

デバッグ中のメッセージ:

55コマ飛ばした!アプリケーションがメイン スレッドで処理しすぎている可能性があります。ターゲット GC ヒープを 49.446MB から 48.000MB にクランプします ターゲット GC ヒープを 49.847MB から 48.000MB にクランプします ターゲット GC ヒープを 49.860MB から 48.000MB にクランプします ターゲット GC ヒープを 49.859MB から 48.000MB にクランプしますターゲット GC ヒープを 49.859MB から 48.000MB に 712 バイトの割り当てでメモリ不足。ターゲット GC ヒープを 49.874MB から 48.000MB にクランプします ターゲット GC ヒープを 49.874MB から 48.000MB にクランプします 964 バイト割り当て用の SoftReferences の収集を強制します ターゲット GC ヒープを 49.874MB から 48.000MB にクランプします 964 バイト割り当てでメモリ不足です。 .Debugging.Evaluation.EvaluatorException: Java.Lang.OutOfMemoryError:

Mono.Debugging.Soft.MethodCall.get_ReturnValue() で

Mono.Debugging.Soft.SoftEvaluationContext.RuntimeInvoke (MethodMirror メソッド、Object ターゲット、Value[] 値) で

Mono.Debugging.Soft.SoftDebuggerAdaptor.CallToString(EvaluationContext ctx, Object obj) で

Mono.Debugging.Evaluation.ObjectValueAdaptor.TargetObjectToObject(EvaluationContext ctx, オブジェクト obj) で

Mono.Debugging.Soft.SoftDebuggerAdaptor.TargetObjectToObject(EvaluationContext gctx, オブジェクト obj) で

Mono.Debugging.Evaluation.ExpressionEvaluator.TargetObjectToExpression(EvaluationContext ctx, Object obj) で

Mono.Debugging.Evaluation.ObjectValueAdaptor.CreateObjectValueImpl 内 (EvaluationContext ctx、IObjectValueSource ソース、ObjectPath パス、オブジェクト obj、ObjectValueFlags フラグ)

Mono.Debugging.Evaluation.ObjectValueAdaptor.CreateObjectValue(EvaluationContext ctx, IObjectValueSource source, ObjectPath path, Object obj, ObjectValueFlags flags) で、ターゲット GC ヒープを 49.874MB から 48.000MB にクランプします ターゲット GC ヒープを 49.874MB から 48.000MB にクランプします SoftReferences のコレクションを強制します964 バイト割り当ての場合 ターゲット GC ヒープを 49.874MB から 48.000MB にクランプする 964 バイト割り当てでメモリ不足。ターゲット GC ヒープを 49.874MB から 48.000MB にクランプ

下手な英語でごめんなさい

4

1 に答える 1

0

次に、ボックスを含むViewPagerを作成し、画像で構成され、記述されます.....各ページは4つのボックスで構成されます。これはボックスを作成するための私のコードです:

 namespace ProvaViewPager.Widget.CatalogoBox

{

    public class CatalogoBox : RelativeLayout

    {

        private LayoutInflater _mInflater;

        private LinearLayout _mBox;



        private void Initialize ()

        {

        }



        public CatalogoBox (IntPtr doNotUse, JniHandleOwnership transfer)

            : base(doNotUse, transfer)

        {

        }



        public CatalogoBox (Context context, IAttributeSet attrs)

            : base(context, attrs)

        {

            InternalCtor (context, attrs);

        }



        public CatalogoBox (Context context, IAttributeSet attrs, int defStyle)

            : base(context, attrs, defStyle)

        {

            InternalCtor (context, attrs);

        }



        ~CatalogoBox ()

        {

            Dispose (false);

        }





        private void InternalCtor (Context context, IAttributeSet attrs)

        {

            _mInflater = (LayoutInflater)context.GetSystemService (Context.LayoutInflaterService);

            _mBox = (LinearLayout)_mInflater.Inflate (Resource.Layout.CatalogoBox, null);

            AddView (_mBox);

        }

    }

}

そしてここ (クラス SwiftView : Fragment) を思い出す:

public override View OnCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

    {

        TextView TxtCDPAR;

        TextView TxtDEPAR;

        TextView TxtPrezzo;

        TextView TxtPz;



        ImageView ImageDisp;

        ImageView ImgFreccia;

        ImageView ImgIncrementa;

        ImageView ImgDecrementa;

        ImageView ImageItem;

        EditText Quantita;

        ImageView ImageProduct;

        LinearLayout BoxAddProdotto;

        View v = inflater.Inflate (Resource.Layout.PageViewXml, container, false);

        if (v != null) {

            #region BOX1

            var BoxProdotto1 = v.FindViewById<ProvaViewPager.Widget.CatalogoBox.CatalogoBox> (Resource.Id.CatalogoBox1);

            TxtCDPAR = BoxProdotto1.FindViewById<TextView> (Resource.Id.CAT_TxtCodiceProdotto);

            TxtDEPAR = BoxProdotto1.FindViewById<TextView> (Resource.Id.CAT_DescrProdotto);

            ImageView ImagetItem1 = BoxProdotto1.FindViewById<ImageView> (Resource.Id.CAT_ImageProduct) as ImageView;

            TxtPz = BoxProdotto1.FindViewById<TextView> (Resource.Id.CAT_NumeroPezzi);

            TxtPrezzo = BoxProdotto1.FindViewById<TextView> (Resource.Id.CAT_TxtPrezzo);

            BoxAddProdotto = BoxProdotto1.FindViewById<LinearLayout> (Resource.Id.BoxAddProdotto);

            ImageDisp = BoxProdotto1.FindViewById<ImageView> (Resource.Id.CAT_ImgDisp);

            ImgFreccia = BoxProdotto1.FindViewById<ImageView> (Resource.Id.CAT_ImgFreccia);

            ImgIncrementa = BoxProdotto1.FindViewById<ImageView> (Resource.Id.imageIncrementa);

            ImgDecrementa = BoxProdotto1.FindViewById<ImageView> (Resource.Id.imageDecrementa);

            Quantita = BoxProdotto1.FindViewById<EditText> (Resource.Id.editNumerico);

            ImageProduct = BoxProdotto1.FindViewById<ImageView> (Resource.Id.CAT_ImageProduct);

            TxtPz.Visibility = ViewStates.Invisible;



            ImagetItem1.SetImageResource (Resource.Drawable.imagespiaggia);



            #endregion



            #region BOX2

            var BoxProdotto2 = v.FindViewById<ProvaViewPager.Widget.CatalogoBox.CatalogoBox> (Resource.Id.CatalogoBox2);

            TxtCDPAR = BoxProdotto2.FindViewById<TextView> (Resource.Id.CAT_TxtCodiceProdotto);

            TxtDEPAR = BoxProdotto2.FindViewById<TextView> (Resource.Id.CAT_DescrProdotto);

            ImageItem = BoxProdotto2.FindViewById<ImageView> (Resource.Id.CAT_ImageProduct) as ImageView;

            TxtPz = BoxProdotto2.FindViewById<TextView> (Resource.Id.CAT_NumeroPezzi);

            TxtPrezzo = BoxProdotto2.FindViewById<TextView> (Resource.Id.CAT_TxtPrezzo);

            BoxAddProdotto = BoxProdotto2.FindViewById<LinearLayout> (Resource.Id.BoxAddProdotto);

            ImageDisp = BoxProdotto2.FindViewById<ImageView> (Resource.Id.CAT_ImgDisp);

            ImgFreccia = BoxProdotto2.FindViewById<ImageView> (Resource.Id.CAT_ImgFreccia);

            ImgIncrementa = BoxProdotto2.FindViewById<ImageView> (Resource.Id.imageIncrementa);

            ImgDecrementa = BoxProdotto2.FindViewById<ImageView> (Resource.Id.imageDecrementa);

            Quantita = BoxProdotto2.FindViewById<EditText> (Resource.Id.editNumerico);

            ImageProduct = BoxProdotto2.FindViewById<ImageView> (Resource.Id.CAT_ImageProduct);

            TxtPz.Visibility = ViewStates.Invisible;



            ImageItem.SetImageResource (Resource.Drawable.feliximage);



            #endregion

これはアダプターです:

namespace ProvaViewPager

{

public class FragmentAdapter : FragmentStatePagerAdapter

{

    int mCount;

    private FragmentManager mFragmentManager;



    public FragmentAdapter (FragmentManager fm) : base (fm)

    {

        mCount = 200;

        mFragmentManager = fm;

    }



    public override Fragment GetItem (int position)

    {

        return new SwiftView (position);

    }



    public override int Count {

        get {

            return mCount;  

        }   

    }



    public override Java.Lang.Object InstantiateItem (ViewGroup container, int position)

    {
        return base.InstantiateItem (container, position);

    }



    public override void DestroyItem (ViewGroup collection, int position, Java.Lang.Object view)

    {

        base.DestroyItem(collection,position,view);



    }

}

}

于 2013-06-11T10:46:36.697 に答える