Quick Scroll Bar in alphabetical order

4

I've already found some examples with a custom view from a list with an quick scroll bar , but I did not really find a scroll bar that really looks like the one in the contacts list my kitkat

I do not understand why this is not a native element, since it's been used on any android since version 4.0.

I have an example using SectionIndexer to sort and divide alphabetically - I did at the time to be like iOS - but it's old and very ugly:

Iwantascrollbarlikethis:

Does anyone have any examples or tips to get me through?

===================================================== ==========================

UPDATE - RESOLVED

I found this example on the Android Developers page, and in the right sidebar you can download the source of a perfect example!

Follow the link

    
asked by anonymous 15.04.2014 / 22:31

2 answers

0

I found this example on the Android Developers page , and in the right sidebar you can Download the source of a perfect example!

  

Retrieving a List of Contacts

     

This lesson shows you how to retrieve a list of contacts whose date matches all or part of a search string, using the following techniques:

     

Match contact names
  Retrieve the list of contacts by matching the search string to all or part of the contact name data. The Contacts Provider allows multiple instances of the same name, so this technique can return the list of matches.

     

Match a specific type of data, such as a phone number
  Retrieve the list of contacts by matching the string to a particular type of detail data such as an email address. For example, this technique allows you to list all of the contacts whose email address matches the search string.

     

Match any type of data
  Retrieve the list of contacts by matching the search string to any type of detail, including name, phone number, street address, email address, and so forth. For example, this technique allows you to accept any type of data for a search string and then list the contacts for which the matches match the string.

     

Note: All the examples in this lesson use the CursorLoader to retrieve data from the Contacts Provider. The CursorLoader runs its query on a thread that is separate from the UI thread. This ensures that the query does not slow down UI response times and causes a poor user experience. For more information, see the Android training class Loading Data in the Background . >

    
24.04.2014 / 22:56
0

XML within a layout:

<ListView
    android:id="@+id/list_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fastScrollEnabled="true"
    android:fastScrollAlwaysVisible="true"
    android:cacheColorHint="@android:color/transparent" />

Activity you need a List of Strings so if you have a complex list you should get the item you need as in the example:

public class Activity extends Activity {

ListView list_view;

private List<MeuItem> items;
private List<String> nomes;
private SimpleAdapter indexAdapter;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);        
    setContentView(R.layout.myview);
    items = new ArrayList<MeuItem>();
    nomes = new ArrayList<String>();

    for (Item i : items) {
        nomes.add(i.getNomeQueEuQueroQueApareca());
    }

    Collections.sort(nomes);
    adapter = new SimpleAdapter(this, nomes);
    list_view.setAdapter(adapter);  

  }
}
    
23.04.2014 / 20:27