In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how Android can achieve the effect of mobile contact column separation. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Effect picture:
The specific code of adapter is as follows:
Public class ContactAdapter extends BaseAdapter {private List contactBeens; private Context context; public ContactAdapter (Context context, List datas) {super (context, datas); this.context = context; contactBeens = datas;} @ Override public View getView (int position, View convertView, ViewGroup parent) {ViewHodler viewHodler = null; if (convertView = = null) {convertView = inflater.inflate ViewHodler = new ViewHodler (convertView); convertView.setTag (viewHodler);} else {viewHodler = (ViewHodler) convertView.getTag ();} viewHodler.name.setText (contactBeens.get (position). GetName ()); viewHodler.number.setText (contactBeens.get (position). GetNumber ()); viewHodler.image.setmBitmap (Analysis (contactBeens.get (position). GetImage () / / get the initials of the current contact name. Among them: the getAlpha () method is a method written by myself (described in detail as follows). The getAlpha () in contactBeens.get (position). GetAlpha () is the get method of the entity class I defined, and the value is the pinyin of the name of the current contact. String currentStr = getAlpha (contactBeens.get (position). GetAlpha ()); / / get the initials of the last contact name String previewStr = (position-1) > = 0? GetAlpha (contactBeens.get (position-1). GetAlpha ()): "; / * the judgment shows that the TextView of # and Amurz is hidden and visible * / if (! previewStr.equals (currentStr)) {viewHodler.alpha.setVisibility (View.VISIBLE); viewHodler.alpha.setText (currentStr) } else {/ / the current contact has the same initials as the previous contact. Execute the following code to hide the alpha (this is the textView I defined). ViewHodler.alpha.setVisibility (View.GONE);} return convertView;} public class ViewHodler {private ContomImage image; private TextView name; private TextView number; private TextView alpha; public ViewHodler (View view) {image = (ContomImage) view.findViewById (R.id.contact_contomImage); name = (TextView) view.findViewById (R.id.contact_name) Number = (TextView) view.findViewById (R.id.contact_number); alpha = (TextView) view.findViewById (R.id.alpha);}} / / return the initials @ NonNull private String getAlpha (String str) {if (str = = null) {return "#" by the contact name str. } if (str.trim (). Length () = 0) {return "#";} char c = str.trim (). Substring (0,1) .charat (0); / / determine whether the initials are if (('a')
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.