Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6059869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:45:38+00:00 2026-05-23T08:45:38+00:00

I would like to know if a ListView in Android has an option to

  • 0

I would like to know if a ListView in Android has an option to place alphabets on the right like the paradigm of iPhone ListView, like below

enter image description here

If yes, can someone provide me with sample codes.

I am not looking for the one with an Alphabet overlay from ApisDemo but an exact one like the iPhone paradigm. Is it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:45:38+00:00Added an answer on May 23, 2026 at 8:45 am

    I implemented somthing similar a while back so i’ve modified my activity and you can take a look below, sorry its not very well commented – hope it helps!

      public class AZIndexer extends Activity {
        ListView myListView;
        ArrayList<String> elements;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            // elements
            String s = "MNBVCXZLKJHGFDSAQWERTYUIOP";
            Random r = new Random();
            elements = new ArrayList<String>();
            for (int i = 0; i < 300; i++) {
                elements.add(s.substring(r.nextInt(s.length())));
            }
            Collections.sort(elements); // Must be sorted!
    
            // listview
            myListView = (ListView) findViewById(R.id.myListView);
            myListView.setFastScrollEnabled(true);
            MyAZAdapter<String> adapter = new MyAZAdapter<String>(
                    getApplicationContext(), android.R.layout.simple_list_item_1,
                    elements);
            myListView.setAdapter(adapter);
    
        }
    
        class MyAZAdapter<T> extends ArrayAdapter<T> implements SectionIndexer {
            ArrayList<String> myElements;
            HashMap<String, Integer> azIndexer;
            String[] sections;
    
            public MyAZAdapter(Context context, int textViewResourceId, List<T> objects) {
                super(context, textViewResourceId, objects);
                myElements = (ArrayList<String>) objects;
                azIndexer = new HashMap<String, Integer>(); //stores the positions for the start of each letter
    
                int size = elements.size();
                for (int i = size - 1; i >= 0; i--) {
                    String element = elements.get(i);
                    //We store the first letter of the word, and its index.
                    azIndexer.put(element.substring(0, 1), i); 
                } 
    
                Set<String> keys = azIndexer.keySet(); // set of letters 
    
                Iterator<String> it = keys.iterator();
                ArrayList<String> keyList = new ArrayList<String>(); 
    
                while (it.hasNext()) {
                    String key = it.next();
                    keyList.add(key);
                }
                Collections.sort(keyList);//sort the keylist
                sections = new String[keyList.size()]; // simple conversion to array            
                keyList.toArray(sections);
            }
    
            public int getPositionForSection(int section) {
                String letter = sections[section];
                return azIndexer.get(letter);
            }
    
            public int getSectionForPosition(int position) {
                Log.v("getSectionForPosition", "called");
                return 0;
            }
    
            public Object[] getSections() {
                return sections; // to string will be called to display the letter
            }
        }
    }
    

    With xml as:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    <ListView 
        android:id="@+id/myListView" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    </ListView>
    </LinearLayout>
    

    ScreenShot:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know how to put all of my ListView rows into
i would like know some reference. I know i can googling it. but prefer
I would like to know if I can open 2 different diagrams using MS
I have a ListView and a DataTable and I would like to know how
I would like to know how to remove an item (which a user can
I would like to know how I can start an Activity from a Preference
I would like to know if it's possible to customize each row of listview?
Would like to know what a programmer should know to become a good at
Would like to know the c# code to actually retrieve the IP type: Static
I would like to know which dependency described in my pom.xml brings a transitive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.