The GridView dynamically adds a view (plus icon), when the data equals 9, the plus icon hides _gridview

Source: Internet
Author: User
    Class Myselectpic extends Baseadapter {@Override public int getcount () {//if (Resul.siz            E () = = 9) {//return resul.size ();//} else {return resul.size () + 1;//
        @Override public Object getitem (int i) {return resul.get (i);
        @Override public long Getitemid (int i) {return i; @Override public View getview (int position, view view, ViewGroup viewgroup) {Viewholder VI
            Ewholder = null;
                if (view = = null) {Viewholder = new Viewholder ();
                view = Getlayoutinflater (). Inflate (R.layout.griditem, ViewGroup, false);


                Viewholder.addimage = (ImageView) View.findviewbyid (R.id.additem);
            View.settag (Viewholder);
            else {Viewholder = (Viewholder) view.gettag (); } if (Position = = Resul.size ()) {//Plus icon ViewHolder.addimage.setImageBitmap (BITMAPFACTORY.DECODERESOURC
                E (Getresources (), r.mipmap.android_icon_addpic_focused));
                if (position = = 9) {viewHolder.addimage.setVisibility (view.gone);
                        } else {//original normal data display, operations, etc. glide.with (firstactivity.this)
                        . Load (resul.get (position)). Placeholder (R.drawable.global_img_default)
            . Centercrop (). into (Viewholder.addimage);

        } return view;
        Class Viewholder {ImageView addimage; }
    }



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.