Android Auto Complete component (Socialtokenautocomplete)--a more friendly way @ Someone in a social app

Source: Internet
Author: User


Project Address: Https://github.com/bitjjj/SocialTokenAutoComplete


code example:


public class Socialtokenactivity extends Activity {Socialcontactscompletionview completionview;    Contact[] people;    Arrayadapter<contact> adapter;        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.layout.activity_demo);                People = new contact[]{new Contact ("Marshall Weir", "[email protected]", r.drawable.author0), New Contact ("Margaret Smith", "[email protected]", R.drawable.author1), New Contact ("Max Jordan" , "[email protected]", R.drawable.author2), New Contact ("Meg Peterson", "[email protected]", R.draw ABLE.AUTHOR3), New Contact ("Amanda Johnson", "[email protected]", R.drawable.author4), n        EW Contact ("Terry Anderson", "[email protected]", r.drawable.author0)};    adapter = new Filteredarrayadapter<contact> (this, r.layout.contact_layout, people) {        @Override public View getView (int position, View Convertview, ViewGroup parent) {if (CO Nvertview = = null) {Layoutinflater L = (layoutinflater) getcontext (). Getsystemservice (activity.layout_i                    Nflater_service);                Convertview = (View) l.inflate (R.layout.contact_layout, parent, false);                The contact P = getItem (position);                ((TextView) Convertview.findviewbyid (R.id.name)). SetText (P.getname ());                ((ImageView) Convertview.findviewbyid (R.id.icon_image)). Setbackgroundresource (P.geticon ());                ((TextView) Convertview.findviewbyid (R.id.email)). SetText (P.getemail ());            return convertview; } @Override protected Boolean keepobject (Contact obj, String mask) {mask = Mask.tolo                Wercase (Locale.getdefault ()); return Mask.contains ("@") && obj.getname (). toLowerCase (Locale.getdefault ()). StartsWith(Mask.substring (Mask.lastindexof ("@") +1));        }        };        Completionview = (Socialcontactscompletionview) Findviewbyid (R.id.searchview);        Completionview.setadapter (adapter);            if (savedinstancestate = = null) {//completionview.setprefix ("to:");            Completionview.addobject (People[0]);        Completionview.addobject (people[1]); }} private void Updatetokenconfirmation () {StringBuilder sb = new StringBuilder ("Current toke        Ns:\n ");            For (Object token:completionView.getObjects ()) {Sb.append (token.tostring ());        Sb.append ("\ n"); }    }   }


Android Auto Complete component (Socialtokenautocomplete)--a more friendly way @ Someone in a social app

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.