5

我的布局非常复杂。我必须使整页可滚动,所以我所做的是 - 我有一个用于我的 gridview 项目的 gridView 适配器和一个具有四个选项卡的自定义适配器,然后我在那个自定义适配器中设置我的 gridview。然后整个视图设置在我的主要活动上,该活动有一个列表视图,所以它现在滚动整页,但问题在于内存。

我在自定义适配器上有 4 个选项卡单击事件,我通过将这些单击事件发送到我有四个 Web 服务的主要活动,并且条件是如果选择了第一个选项卡,则将发生第一个 Web 服务调用并设置新适配器关于主要活动。

问题:当我单击第一个选项卡时,我的内存大小为 130 MB,单击第二个选项卡时它会增加一倍,所以当我单击第三个选项卡时也会发生同样的事情。我正在使用延迟加载来加载我的图像,这也维护了我的缓存,我尝试了 clear()、notifyDataSetChanged() 但没有做任何更改。每次点击标签时,我的记忆都会增加。

这是我的代码:

GallaryLoginMainActivity

      public class GallaryLoginMainActivity<T> extends BaseClass {
    
        /**
         * Description:Declare the UI components.
         */
    
        private List<ArrayList<HashMap<String, String>>> data = null;
        private ListView lstGallaryMain = null;
        public ArrayList<HashMap<String, String>> userDataActivity;
        public ArrayList<HashMap<String, String>> userDataSecondActivity;
        private ProgressDialog loadingDialog = null;
        LinkedHashMap<String, String> linkedMap;
        ArrayList<Assignment> assignmentArrayList;
        private String selectedTab = "popular";
        private ImageLoader imageloader;
    
        // public static ArrayAdapter mAdapter;
        public ArrayAdapter mAdapter;
    
        /**
         * Description:This method use for prepare the request to get the response
         * from API
         * 
         */
    
        public void MediaGetFiles() {
    
            final GallerySaxParserForGetFiles gsp = new GallerySaxParserForGetFiles();
            final RestService restService = new RestService();
    
            try {
                linkedMap = new LinkedHashMap<String, String>();
                gsp.parseXML(restService.getResponse());
                // userDataActivity = new ArrayList<HashMap<String, String>>();
                userDataActivity = gsp.userData;
                System.out.println("RR : userDataActivity from LoginMainAct :" + userDataActivity.size());
                System.out.println("RR : from userdataactivty for item:" + userDataActivity.get(0).toString());
                data.add(userDataActivity);
    
            } catch (Exception e) {
    
                e.printStackTrace();
            }
    
        }
    
        /**
         * Description:This method use for prepare the request to get the response
         * from API
         * 
         */
    
        public void MediaGetFilesInfo() {
    
            // new Thread(new Runnable() {
    
            // public void run() {
    
            GallerySaxParserForGetFileInfo gisp = new GallerySaxParserForGetFileInfo();
    
            try {
    
                RestService restService = new RestService();
                linkedMap = new LinkedHashMap<String, String>();
                System.out.println("From GallaryUserLoginMainActivity1 : " + restService.getResponse());
                gisp.parseXML(restService.getResponse());
                userDataSecondActivity = new ArrayList<HashMap<String, String>>();
                userDataSecondActivity = gisp.userSecondData;
                data.add(userDataSecondActivity);
    
            } catch (Exception e) {
    
                e.printStackTrace();
            }
    
            // }
            // }).start();
    
        }
    
        /**
         * Description:This method use for prepare the request to get the response
         * from API
         * 
         */
    
        public void MediaGetShortedFilesByPopuler() {
    
            final GallerySaxParserForGetFiles gsp = new GallerySaxParserForGetFiles();
            final RestService restService = new RestService();
            try {
                linkedMap = new LinkedHashMap<String, String>();
                
                gsp.parseXML(restService.getResponse());
                userDataActivity = new ArrayList<HashMap<String, String>>();
                userDataActivity = gsp.userData;
                data.add(userDataActivity);
                data.add(userDataSecondActivity);
                // };
    
                // }.execute();
    
            } catch (Exception e) {
    
                e.printStackTrace();
            }
    
        }
    
        /**
         * Description:This method use for prepare the request to get the response
         * from API
         * 
         */
        public void MediaGetShortedFilesByRecent() {
    
            final GallerySaxParserForGetFiles gsp = new GallerySaxParserForGetFiles();
            final RestService restService = new RestService();
            try {
                linkedMap = new LinkedHashMap<String, String>();
            
                gsp.parseXML(restService.getResponse());
                userDataActivity = new ArrayList<HashMap<String, String>>();
                userDataActivity = gsp.userData;
                data.add(userDataActivity);
                data.add(userDataSecondActivity);
            } catch (Exception e) {
                e.printStackTrace();
            }
    
        }
    
        /**
         * Description:This method use for prepare the request to get the response
         * from API
         * 
         */
    
        public void MediaGetShortedFilesByComment() {
    
            final GallerySaxParserForGetFiles gsp = new GallerySaxParserForGetFiles();
            final RestService restService = new RestService();
            try {
                linkedMap = new LinkedHashMap<String, String>();
        
                gsp.parseXML(restService.getResponse());
                userDataActivity = new ArrayList<HashMap<String, String>>();
                userDataActivity = gsp.userData;
                data.add(userDataActivity);
                data.add(userDataSecondActivity);
            } catch (Exception e) {
    
                e.printStackTrace();
            }
    
        }
    
        /**
         * Description:This method use for prepare the request to get the response
         * from API
         * 
         */
    
        public void MediaGetShortedFilesByNearBy() {
    
            final GallerySaxParserForGetFiles gsp = new GallerySaxParserForGetFiles();
            final RestService restService = new RestService();
            try {
                linkedMap = new LinkedHashMap<String, String>();
            
                gsp.parseXML(restService.getResponse());
                userDataActivity = new ArrayList<HashMap<String, String>>();
                userDataActivity = gsp.userData;
                data.add(userDataActivity);
                data.add(userDataSecondActivity);
            } catch (Exception e) {
    
                e.printStackTrace();
            }
    
        }
    
        /** Called when the activity is first created. */
        @Override
        protected void onCreate(Bundle savedInstanceState) {
    
            super.onCreate(savedInstanceState);
            setContentView(R.layout.gallary_login_main_page_list);
            init(GallaryLoginMainActivity.this, R.id.main, getIntent());
            data = new ArrayList<ArrayList<HashMap<String, String>>>();
    
            imageloader = new ImageLoader(getApplicationContext());
    
            Intent intent = getIntent();
            if (intent.getExtras().getString("SELECTED_TAB") != null) {
                selectedTab = intent.getExtras().getString("SELECTED_TAB");
            }
    
                /*
                 * 
                 * This method is used to Show The loading dialog till the data
                 * loads for main page.
                 */
    
                new AsyncTask<Void, Void, Void>() {
                    protected void onPreExecute() {
    
                        loadingDialog = ProgressDialog.show(GallaryLoginMainActivity.this, "", "Loading. Please wait...", true);
                    }
    
                    @Override
                    protected Void doInBackground(Void... params) {
    
                        return null;
                    };
    
                    protected void onPostExecute(Void result) {
    
                        if (selectedTab.equalsIgnoreCase("popular")) {
    
                            MediaGetShortedFilesByPopuler();
                        } else if (selectedTab.equalsIgnoreCase("recent")) {
    
                            MediaGetShortedFilesByRecent();
                        } else if (selectedTab.equalsIgnoreCase("commented")) {
    
                            MediaGetShortedFilesByComment();
                        }
                        if (mAdapter != null) {
                            mAdapter = null;
                            mAdapter.clear();
    
                        }
                        if (mAdapter == null) {
    
                            lstGallaryMain = (ListView) findViewById(R.id.lstGallaryMain);
                            mAdapter = new GalleryCustomAdapterForMainPage<T>(GallaryLoginMainActivity.this, data);
                            
                            // mAdapter.notifyDataSetChanged();
                        }
                        lstGallaryMain.setAdapter(mAdapter);
                        if (loadingDialog != null && loadingDialog.isShowing()) {
                            loadingDialog.dismiss();
                        }
                    };
                }.execute();
            }
    
        }
    
        @Override
        protected void onResume() {
            System.gc();
            super.onResume();
        }
    
    
    
        @Override
        protected void onPause() {
            super.onPause();
            System.gc();
        }
    
        @Override
        public void onLowMemory() {
            super.onLowMemory();
            imageloader.clearCache();
        }
    
        @Override
        protected void onDestroy() {
            lstGallaryMain.setAdapter(null);
            userDataActivity = null;
            userDataSecondActivity = null;
    
            System.gc();
            super.onDestroy();
        }
    
    }
    

GalleryCustomAdapterForMainPage

    public class GalleryCustomAdapterForMainPage<T> extends ArrayAdapter<T> {
        public static int gridviewHeight = 0;
        private GridView refGridView;
        /**
         * Description:Declare the UI components.
         */
        List<ArrayList<HashMap<String, String>>> data = null;
        public ArrayList<HashMap<String, String>> userDataActivity;
        public ArrayList<HashMap<String, String>> userDataSecondActivity;
        private ProgressDialog loadingDialog = null;
        // AQuery listAQ;
    
        private Activity mContext = null;
        private LayoutInflater inflater = null;
        Bitmap galleryBitmapHadnling = null;
        private PopupWindow mpopup;
        LinkedHashMap<String, String> linkedMap;
        Holder1 h1;
        GalleryMainActivityGridViewAdapter gmaga = null;
        
        private ImageLoader imageloader;
    
        /**
         * This method is use to set object that will control the listview
         * 
         * @param activity
         *            that creates this thing
         * @param data
         *            bind to this listview
         */
    
        // This Class is used to Declare a CustomAdapter that we use to join the
        // data set and the ListView
    
        public GalleryCustomAdapterForMainPage(Activity activity, List data) {
            super(activity, R.layout.gallery_main_page_content, data);
    
            this.mContext = activity;
            // listAQ = new AQuery(mContext);
            this.data = data;
            this.userDataActivity = this.data.get(0);
            System.out.println("userDataActivity is : " + userDataActivity);
            this.userDataSecondActivity = this.data.get(1);
            // listAQ = new AQuery(mContext);
            // Get a new instance of the layout view
            inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            imageloader = new ImageLoader(mContext);
        }
        
        // Total number of things contained within the adapter
        @Override
        public int getCount() {
    
            return this.data.size() - 1;
        }
    
        // create View for each item referenced by the Adapter
        @SuppressWarnings("deprecation")
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
    
            if (convertView == null) {
                /* create a new view of our layout and inflate it in the row */
                // Inflate the layout
                convertView = inflater.inflate(R.layout.gallery_main_page_content, null);
                // System.gc();
                h1 = new Holder1();
    
                // Initialize the UI components
                h1.imgView_Gallery_Main_Background = (ImageView) convertView.findViewById(R.id.imgView_Gallery_Main_Background);
    
                h1.txtView_main_img_title = (TextView) convertView.findViewById(R.id.txtView_main_img_title);
                Typeface typeForTitile = Typeface.createFromAsset(getContext().getAssets(), "fonts/helvetica_bold_neue.ttf");
                h1.txtView_main_img_title.setTypeface(typeForTitile);
    
                h1.texView_featured = (TextView) convertView.findViewById(R.id.texView_featured);
                Typeface typeForFeatured = Typeface.createFromAsset(getContext().getAssets(), "fonts/gotham_black_1.ttf");
                h1.texView_featured.setTypeface(typeForFeatured);
    
                h1.txtView_assignment_detail = (TextView) convertView.findViewById(R.id.txtView_assignment_detail);
                Typeface typeAssignmentDetail = Typeface.createFromAsset(getContext().getAssets(), "fonts/arial_bold_1.ttf");
                h1.txtView_assignment_detail.setTypeface(typeAssignmentDetail);
    
                h1.imgView_Main_TumbNail = (ImageView) convertView.findViewById(R.id.imgView_Main_TumbNail);
    
                h1.txtView_gallery_main_person_name = (TextView) convertView.findViewById(R.id.txtView_gallery_main_person_name);
                Typeface txtViewPersonName = Typeface.createFromAsset(getContext().getAssets(), "fonts/arial_bold.ttf");
                h1.txtView_gallery_main_person_name.setTypeface(txtViewPersonName);
    
                h1.txtView_gallery_main_views = (TextView) convertView.findViewById(R.id.txtView_gallery_main_views);
                Typeface txtViewViews = Typeface.createFromAsset(getContext().getAssets(), "fonts/arial_bold.ttf");
                h1.txtView_gallery_main_views.setTypeface(txtViewViews);
    
                h1.texView_gallery_main_comment = (TextView) convertView.findViewById(R.id.texView_gallery_main_comment);
                Typeface txtViewComments = Typeface.createFromAsset(getContext().getAssets(), "fonts/arial_bold.ttf");
                h1.texView_gallery_main_comment.setTypeface(txtViewComments);
    
                h1.texView_gallery_main_favorite = (TextView) convertView.findViewById(R.id.texView_gallery_main_favorite);
                Typeface txtViewFavorite = Typeface.createFromAsset(getContext().getAssets(), "fonts/arial_bold.ttf");
                h1.texView_gallery_main_favorite.setTypeface(txtViewFavorite);
    
                h1.btn_Gallery_Main_ShowMe = (RadioButton) convertView.findViewById(R.id.btn_Gallery_Main_ShowMe);
    
                h1.btn_Gallery_Tab_Popular = (RadioButton) convertView.findViewById(R.id.btn_Gallery_Tab_Popular);
                Typeface TabPopular = Typeface.createFromAsset(getContext().getAssets(), "fonts/helvetica_ce_regular.ttf");
                h1.btn_Gallery_Tab_Popular.setTypeface(TabPopular);
                h1.btn_Gallery_Tab_Popular.setChecked(true);
    
                h1.btn_Gallery_Tab_recent = (RadioButton) convertView.findViewById(R.id.btn_Gallery_Tab_recent);
                Typeface TabRecent = Typeface.createFromAsset(getContext().getAssets(), "fonts/helvetica_ce_regular.ttf");
                h1.texView_gallery_main_favorite.setTypeface(TabRecent);
    
                h1.btn_Gallery_Tab_Commented = (RadioButton) convertView.findViewById(R.id.btn_Gallery_Tab_Commented);
                Typeface TabCommented = Typeface.createFromAsset(getContext().getAssets(), "fonts/helvetica_ce_regular.ttf");
                h1.texView_gallery_main_favorite.setTypeface(TabCommented);
    
                h1.btn_Gallery_Tab_Nearby = (RadioButton) convertView.findViewById(R.id.btn_Gallery_Tab_Nearby);
                Typeface TabNearby = Typeface.createFromAsset(getContext().getAssets(), "fonts/helvetica_ce_regular.ttf");
                h1.texView_gallery_main_favorite.setTypeface(TabNearby);
    
                h1.imgView_ForPlayVideo = (ImageView) convertView.findViewById(R.id.imgView_ForPlayVideo);
    
                if (userDataActivity.get(position).get("filetype").toString().endsWith("1")) {
                    h1.imgView_ForPlayVideo.setVisibility(View.GONE);
                } else {
                    h1.imgView_ForPlayVideo.setVisibility(View.VISIBLE);
                } // set the content in grid view of gallery main page
    
                h1.gridview_Gallery = (GridView) convertView.findViewById(R.id.gridview_Gallery);
    
                int gridHeight = (int) ((userDataActivity.size() / 3) * 140 * 1.80);
                System.out.println("gridHeigh is : " + gridHeight);
    
                if (h1.btn_Gallery_Tab_Popular != null) {
    
                    h1.txtView_gallery_main_person_name.setText("   " + userDataActivity.get(position).get("user_name"));
                    h1.txtView_main_img_title.setText(userDataActivity.get(position).get("title"));
                    h1.txtView_gallery_main_views.setText("     |  " + userDataActivity.get(position).get("hits") + " views");
                    h1.texView_gallery_main_comment.setText("     |  " + userDataActivity.get(position).get("commentcount") + "        ");
                    h1.texView_gallery_main_favorite.setText("     |  " + userDataActivity.get(position).get("votecount") + "        ");
    
                    imageloader.DisplayImage(userDataActivity.get(position).get("thumbUrl") + "/12", h1.imgView_Gallery_Main_Background);
    
                    // h1.imgView_Main_TumbNail.setImageBitmap(getBitmap(userDataActivity.get(position).get("thumbUrl")
                    // + "/12"));
    
                    if (userDataActivity.get(position).get("publicUrl") != null) {
    
                        imageloader.DisplayImage(userDataActivity.get(position).get("publicUrl") + "/14", h1.imgView_Gallery_Main_Background);
    
                    } else {
    
                        h1.imgView_Gallery_Main_Background.setBackgroundResource(R.drawable.loading);
                    }
    
                }
    
                userDataActivity.remove(0);
                if (h1.gridview_Gallery != null) {
                    // clearAdapter();
                    // setting the adapter
                    // if (gmaga == null) {
                    gmaga = new GalleryMainActivityGridViewAdapter(mContext, userDataActivity);
    
                    // }
                    h1.gridview_Gallery.setAdapter(gmaga);
    
                    // Total number of things contained within the adapter
    
                    int gridHeight1 = (int) ((h1.gridview_Gallery.getAdapter().getCount() / 3) * 120 * 1.80);
                    h1.gridview_Gallery.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, gridHeight1));
                    h1.gridview_Gallery.setSelector(new ColorDrawable(color.transparent));
    
                    h1.gridview_Gallery.setOnItemClickListener(new OnItemClickListener() {
    
                        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
    
                            Intent intent = new Intent(mContext, GalleryDetailPageActivity.class);
    
                            System.out.println("pos:" + userDataActivity.get(position).get("id"));
    
                            // This will send the items via intent to Gallery detail
                            // page to display data on that page.
    
                        
                            
                            intent.putExtra("tabId", R.id.tab_b01);
                            intent.putExtra("tabBackgroundId", R.drawable.tab_b01_on);
                            mContext.startActivity(intent);
    
                        }
    
                    });
                }
    
                if (h1.btn_Gallery_Tab_Popular != null) {
    
                    h1.btn_Gallery_Tab_Popular.setOnClickListener(new OnClickListener() {
    
                        public void onClick(View v) {
                            Intent intent = new Intent(mContext, GallaryLoginMainActivity.class);
                            intent.putExtra("SELECTED_TAB", "popular");
                            intent.putExtra("tabId", R.id.tab_b01);
                            intent.putExtra("tabBackgroundId", R.drawable.tab_b01_on);
                            mContext.startActivity(intent);
                            mContext.finish();
                            // }
    
                        }
                    });
                }
    
                if (h1.btn_Gallery_Tab_recent != null) {
                    h1.btn_Gallery_Tab_recent.setOnClickListener(new OnClickListener() {
    
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(mContext, GallaryLoginMainActivity.class);
                            intent.putExtra("SELECTED_TAB", "recent");
                            intent.putExtra("tabId", R.id.tab_b01);
                            intent.putExtra("tabBackgroundId", R.drawable.tab_b01_on);
                            mContext.startActivity(intent);
                            mContext.finish();
    
                            // }
    
                        }
                    });
                }
    
                if (h1.btn_Gallery_Tab_Commented != null) {
    
                    h1.btn_Gallery_Tab_Commented.setOnClickListener(new OnClickListener() {
    
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(mContext, GallaryLoginMainActivity.class);
                            intent.putExtra("SELECTED_TAB", "commented");
                            intent.putExtra("tabId", R.id.tab_b01);
                            intent.putExtra("tabBackgroundId", R.drawable.tab_b01_on);
                            mContext.startActivity(intent);
                            mContext.finish();
                            // }
    
                        }
                    });
    
                }
                    convertView.setTag(h1);
    
            }
            return convertView;
    
        }
    
        private class Holder1 {
    
            ImageView imgView_Gallery_Main_Background;
            TextView txtView_main_img_title;
            TextView texView_featured;
            RadioButton btn_Gallery_Tab_Popular;
            RadioButton btn_Gallery_Tab_recent;
            RadioButton btn_Gallery_Tab_Commented;
            RadioButton btn_Gallery_Tab_Nearby;
            ImageView imgView_Main_TumbNail;
            TextView txtView_assignment_detail;
            TextView txtView_assignment_name;
            TextView txtView_gallery_main_person_name;
            TextView txtView_gallery_main_views;
            TextView texView_gallery_main_comment;
            TextView texView_gallery_main_favorite;
            RadioButton btn_Gallery_Main_ShowMe;
            GridView gridview_Gallery;
            ImageView imgView_ForPlayVideo;
        }
    
    }

GalleryMainActivityGridViewAdapter

public class GalleryMainActivityGridViewAdapter extends BaseAdapter {

    // AQuery listAQ;
    private Context mContext;
    int layoutResourceId;
    ArrayList<HashMap<String, String>> dataArray;
    ArrayList<Boolean> selected;
    private GallerySmartLazyLoader lazyloader;
    private ImageLoader imageloder;

    public static String dataExtension = " Views";



    public GalleryMainActivityGridViewAdapter(Context context, ArrayList<HashMap<String, String>> resultArray) {
        this.mContext = context;
        // this.layoutResourceId = layoutId;
        this.dataArray = resultArray;
        // listAQ = new AQuery(mContext);
        lazyloader = new GallerySmartLazyLoader(mContext);
        imageloder = new ImageLoader(mContext.getApplicationContext());
        // aa = new ArrayAdapter<Photo>(mContext, layoutResourceId);
    }

    public int getCount() {
        return dataArray.size();
    }

    public void clear() {
        dataArray.clear();

    }

    public Object getItem(int position) {
        return position;
    }

    public long getItemId(int position) {
        return position;
    }

    // BitmapFactory.Options options = null;
    // Bitmap cachedImage;

    @SuppressWarnings("deprecation")
    public View getView(int position, View convertView, ViewGroup parent) {
        String url = null;
        GalleryHolder holder = null;

        if (convertView == null) {
            convertView = ((LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.gallery_main_page_grid_item, parent, false);
            convertView.setTag(holder);

        } else {
            holder = (GalleryHolder) convertView.getTag();
        }

        holder = new GalleryHolder();

        try {

            String thumbnail = dataArray.get(position).get("thumbUrl") + "/11";

            holder.imgView_Grid_Thumbnail_Gallery = (ImageView) convertView.findViewById(R.id.imgView_Grid_Thumbnail_Gallery);
            if (holder.imgView_Grid_Thumbnail_Gallery != null) {

            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        holder.txtView_Grid_Name_Gallery = (TextView) convertView.findViewById(R.id.txtView_Grid_Name_Gallery);
        Typeface TabGridname = Typeface.createFromAsset(convertView.getContext().getAssets(), "fonts/arial_bold.ttf");
        holder.txtView_Grid_Name_Gallery.setTypeface(TabGridname);

        if (holder.txtView_Grid_Name_Gallery != null) {

            // holder.txtView_Grid_Name_Gallery.getId()).text(dataArray.get(position).get("user_name"));
            holder.txtView_Grid_Name_Gallery.setText(dataArray.get(position).get("user_name"));
            Typeface txtViewForName = Typeface.createFromAsset(convertView.getContext().getAssets(), "fonts/arial_bold.ttf");
            holder.txtView_Grid_Name_Gallery.setTypeface(txtViewForName);

        }

        ImageView v = holder.imgView_GridItem_Gallery = (ImageView) convertView.findViewById(R.id.imgView_GridItem_Gallery);

        if (holder.imgView_GridItem_Gallery != null) {
            String publicUrl = dataArray.get(position).get("publicUrl") + "/14";

            imageloder.DisplayImage(publicUrl, holder.imgView_GridItem_Gallery);

        }
        holder.txtView_Grid_Views_Gallery = (TextView) convertView.findViewById(R.id.txtView_Grid_Views_Gallery);
        Typeface TabGriddetail = Typeface.createFromAsset(convertView.getContext().getAssets(), "fonts/helvetica_ce_regular.ttf");
        holder.txtView_Grid_Name_Gallery.setTypeface(TabGriddetail);

        if (holder.txtView_Grid_Views_Gallery != null) {

            if (isPopuler) {
                holder.txtView_Grid_Views_Gallery.setText(dataArray.get(position).get("hits") + dataExtension);

            }

            else if (isUpload) {
                GalleryMainActivityGridViewAdapter.dataExtension = dataArray.get(position).get("upload");
                holder.txtView_Grid_Views_Gallery.setText(dataArray.get(position).get("upload"));

            }

            else if (isComments) {

                holder.txtView_Grid_Views_Gallery.setText(dataArray.get(position).get("commentcount") + dataExtension);

            }
            // else if (isNearby) {
            // aq.id(holder.txtView_Grid_Views_Gallery.getId()).text(dataArray.get(position).get("commentcount")
            // + dataExtension);
            // }

            Typeface txtViewForViews = Typeface.createFromAsset(convertView.getContext().getAssets(), "fonts/arial_bold.ttf");
            holder.txtView_Grid_Views_Gallery.setTypeface(txtViewForViews);
        }

        holder.imgView_Grid_PlayVideo = (ImageView) convertView.findViewById(R.id.imgView_Grid_PlayVideo);
        if (holder.imgView_Grid_PlayVideo != null) {

            if (dataArray.get(position).get("filetype").toString().equals("1")) {
                holder.imgView_Grid_PlayVideo.setVisibility(View.GONE);
            } else {
                holder.imgView_Grid_PlayVideo.setVisibility(View.VISIBLE);
            }
        }

        return convertView;

    }

    

    class GalleryHolder {
        ImageView imgView_Grid_PlayVideo;
        ImageView imgView_Grid_Thumbnail_Gallery;
        TextView txtView_Grid_Views_Gallery;
        TextView txtView_Grid_Name_Gallery;
        ImageView imgView_GridItem_Gallery;
    }

}

图片

在此处输入图像描述

4

1 回答 1

0

您显示的描述表明可能存在内存泄漏。检查我对这个问题的回答。我的猜测是您应该在代码中使用Application上下文而不是Activity上下文。使用提到的答案中的视频来了解如何识别泄漏。

于 2012-09-18T14:28:02.607 回答