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

Tangyuan or Yuanxiao? Note that these 4 types of people are advised to eat less!

Today is the Lantern Festival. Are you ready to e...

Zhihu product analysis report!

Preface As Internet traffic has peaked, new traff...

Why do sunflowers follow the sun? Scientists discover new mechanism →

Compiled by: Gong Zixin sunflower Known for its a...

9 key points for a complete event planning program!

In marketing operations, marketing activities, as...

Essential knowledge for App promotion and operation: App channel statistics!

In this article, the author will tell you: What a...

How can we make them have more monkeys? The keepers are really worried

Key Points ★ Due to hunting and habitat shrinkage...

Cats have given so much for human health and scientific progress!

In the field of life science and medical research...

Review of Pinduoduo’s gameplay in 2019: branding and hit products!

Today I will mainly share with you some trial and...

618 sprint! How to increase brand transactions on Xiaohongshu?

The 618 promotion has entered the sprint period, ...

The “universal” methodology for bidding advertising!

The editor has personally operated and placed adv...