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