Please refer to the following code for XML.
<?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> import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Random; import java.util.Set; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.util.Log; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.SectionIndexer; public class AlphabetIndexer extends Activity { ListView myListView; ArrayList<String> elements; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);
user1210558
source share