Android Loading System Gallery

Source: Internet
Author: User

 Public classMainactivityextendsActivityImplementsLoadercallbacks<cursor>{    PrivateListView listview=NULL; PrivateUri uri=NULL; PrivateContentresolver resolver=NULL; PrivateCursorloader cursorloader=NULL; Privatestring[] Projection =NewString[]{mediastore.images.media._id,mediastore.images.media.bucket_display_name}; PrivateSimplecursoradapter cursoradapter=NULL; Private Long[] IDs =NULL; PrivateLoadermanager loadermanager=NULL; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.activity_main); ListView=(ListView) Findviewbyid (R.id.listview); //gets the URI of the media pictureUri=MediaStore.Images.Media.EXTERNAL_CONTENT_URI; Resolver=Getcontentresolver (); Cursorloader=NewCursorloader ( This, Uri, projection,NULL,NULL,NULL); CursorAdapter=NewSimplecursoradapter ( This, R.layout.item,NULL, Projection,New int[]{r.id.textview_id,r.id.textview_name}, Simplecursoradapter.flag_register_content_observer);        Listview.setadapter (CursorAdapter); //get the ID of all the entriesids=Listview.getcheckeditemids (); Listview.setonitemclicklistener (NewOnitemclicklistener () {@Override Public voidOnitemclick (adapterview<?> Parent, view view,intPositionLongID) {IDs=Listview.getcheckeditemids (); TextView textview_id=(TextView) View.findviewbyid (r.id.textview_id); TextView Textview_name=(TextView) View.findviewbyid (r.id.textview_name); BooleanFLG =false;  for(inti = 0; i < ids.length; i++) {                                        if(id==Ids[i])                        {Textview_id.settextcolor ((color.blue));                        Textview_name.settextcolor (Color.Blue); FLG=true; }                                    }                                if(!FLG)                    {Textview_id.settextcolor ((color.black));                Textview_name.settextcolor (Color.Black);                }            }        }); Loadermanager=Getloadermanager (); Loadermanager.initloader (2,NULL, This); } @Override PublicLoader<cursor> Oncreateloader (intID, Bundle args) {        //TODO auto-generated Method Stub        returnCursorloader; } @Override Public voidOnloadfinished (loader<cursor>loader, Cursor data) {        //TODO auto-generated Method Stubcursoradapter.swapcursor (data); } @Override Public voidOnloaderreset (loader<cursor>loader) {        //TODO auto-generated Method StubCursoradapter.swapcursor (NULL); }        }

Android Loading System Gallery

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.