ListView with alphabets on the right like Sony Xperia Contacts, is it possible?

I searched for one day to find an example or library that can do this for me, see below:

wo9II.jpg

If you are a Sony Xperia user, you know exactly what I am asking for, as you can see in the picture, the user can touch the alphabets and move them to the left. Moving on, the alphabets will be larger.

I have seen several questions on stackoverflow, but none of them matched my requirement. And what I have tried is the same as usual.

Here is a question about StackOverFlow: ListView with alphabet .... And there are many other links I read, I can provide one too.

+3


source to share


1 answer


To do this you need a ListView

custom header with support.

If you don't want your hand to be messy and look like a much simpler solution, try this library called SuperSLIM.

See example below,

enter image description here



You can check out the default sample application that demonstrates the use of a custom title, especially in alphabetical order.

https://github.com/TonicArtos/SuperSLiM/tree/early_release_4/example

See an example from the demo app for implementing the title in alphabetical order,

public CountryNamesAdapter(Context context, int headerMode) {
        mContext = context;

        final String[] countryNames = context.getResources().getStringArray(R.array.country_names);
        mHeaderDisplay = headerMode;

        mItems = new ArrayList<>();

        //Insert headers into list of items.
        String lastHeader = "";
        int sectionManager = -1;
        int headerCount = 0;
        int sectionFirstPosition = 0;
        for (int i = 0; i < countryNames.length; i++) {
            String header = countryNames[i].substring(0, 1);
            if (!TextUtils.equals(lastHeader, header)) {
                // Insert new header view and update section data.
                sectionManager = (sectionManager + 1) % 2;
                sectionFirstPosition = i + headerCount;
                lastHeader = header;
                headerCount += 1;
                mItems.add(new LineItem(header, true, sectionManager, sectionFirstPosition));
            }
            mItems.add(new LineItem(countryNames[i], false, sectionManager, sectionFirstPosition));
        }
    }

      

0


source







All Articles