Android custom ListView to implement contact sorting

Android custom ListView to implement contact sorting

Source code introduction

Android custom LISTVIEW realizes the effect of contact sorting, which is convenient to use.

Source code running screenshot

Source code snippet

  1. @Override  
  2. public View getLetterView( int position, View convertView, ViewGroup parent) {
  3. // Here is the item interface setting for letters.  
  4. if (convertView == null ) {
  5. convertView = new TextView(MainActivity. this );
  6. ((TextView) convertView).setGravity(Gravity.CENTER_VERTICAL);
  7. convertView.setBackgroundColor(getResources().getColor(android.R.color.white));
  8. }
  9. ((TextView) convertView).setText(list.get(position).getValue());
  10.   
  11. return convertView;
  12. }
  13.   
  14. @Override  
  15. public View getContainerView( int position, View convertView, ViewGroup parent) {
  16. // Here are the item interface settings for other normal data.  
  17. if (convertView == null ) {
  18. convertView = new TextView(MainActivity. this );
  19. ((TextView) convertView).setGravity(Gravity.CENTER_VERTICAL);
  20. }
  21. ((TextView) convertView).setText(list.get(position).getValue());
  22.   
  23. return convertView;
  24. }

Source code link: http://download..com/data/1968342

<<:  bmob personal lost property application_app development template

>>:  Android-menudrawer-master open source powerful sidebar menu

Recommend

Finally, today the health code will be unified!

I have waited for a long time and finally waited ...

Mom, mom, mom, why is my body feeling so numb?

Whenever we came out of the bathroom, staggering ...

How long will it take for your job to be replaced by a machine?

Many people believe that the world is about to us...

What changes will happen to your body after you overeat? (Besides getting fat)

Hey guys, have you ever had a moment like this? F...

A guide to private domain traffic for restaurants!

Between 2020 and 2021, various catering companies...

Why is live streaming app development so popular?

Nowadays, the development of various mass communi...

4 ways to design the background image of the new media Douyin homepage

After completing the account positioning planning...

Stunning and stunning, how are these atmospheric wonders formed?

Produced by: Science Popularization China Author:...

Tesla officially announced its plan to build a factory in Shanghai

Electric car manufacturer Tesla's plan to bui...

What is play therapy? Can it really cure illness?

In this era full of laughter and joy, every child...

Is a food blender a nutrient absorption booster or just a waste of money?

In recent years, food wall breakers have graduall...

Yu Yang of Analysys: Data is the new energy in the future Internet world

On March 19, Analysys officially launched its dat...