androidlistviewfastscroll

Alphabetical FastScroll


I am trying to create a fast Scroll with Alphabetical letters. Can somebody tell me how can I use the code in this question in another class? I have a class with a method that returns letters I need to put in the fast scroll, so I want to use this class in another one, like this:

MyListAdaptor mla = new MyListAdaptor(getApplicationContext(), itemsBP);
mla.xyz();

but then I don't know how I can make the letters appear.

If you can, help me please.


Solution

  • At the end of some research I realized that what was missing was the following code, which must be placed in OnCreate ():

    LinkedList <String> mLinked <String> = new LinkedList ();
    for (int i = 0; i <nomes.length: i + +) {
    mLinked.add (names [i]);
    }
    
    setListAdapter (new MyListAdaptor (this, mLinked));
    
    ListView lv = getListView ();
    lv.setFastScrollEnabled (true);
    
    lv.setOnItemClickListener (new OnItemClickListener () {
    public void onItemClick (AdapterView <?> parent, View view,
    int position, long id) {
    / / When clicked, show a toast with the TextView text
    
    
    Toast.makeText (getApplicationContext (), ((TextView) view). GetText (). ToString (), Toast.LENGTH_SHORT.) Show ();
    }
    });
    

    And put the class code within the class MyListAdaptor Main OnCreate ().

    Thanks for the help and hopefully this can help others in the future.