ListView in Alphabetic Order in ANDROID

Posted by Unknown Jumat, 01 Maret 2013 0 komentar
Java class: 
public class MainActivity extends ListActivity {
static final String[] items = new String[] { "Babbage","Boole", "Berners-Lee",
"Atanasoff", "Allen","Cormack", "Cray","Dijkstra","Dix","Dewey",
"Erdos","Zebra" };

ArrayAdapter<string> arrayadapter;
ListView listview;
ArrayList<string> arraylist;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
arraylist= new ArrayList<String>();
for(int i=0;i<items.length;i++)
{
arraylist.add(FRUITS[i]);
}
Collections.sort(arraylist );//for sorting arraylist
arrayadapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,arraylist);
listview=getListView();
listview.setAdapter(arrayadapter);
listview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent,View view,
int position, long id)
{
Toast.makeText(getApplicationContext(),
((TextView) view).getText(), Toast.LENGTH_SHORT).show();
}});}}
                 
TERIMA KASIH ATAS KUNJUNGAN SAUDARA
Judul: ListView in Alphabetic Order in ANDROID
Ditulis oleh Unknown
Rating Blog 5 dari 5
Semoga artikel ini bermanfaat bagi saudara. Jika ingin mengutip, baik itu sebagian atau keseluruhan dari isi artikel ini harap menyertakan link dofollow ke https://androidpopuler.blogspot.com/2013/03/listview-in-alphabetic-order-in-android.html. Terima kasih sudah singgah membaca artikel ini.

0 komentar:

Posting Komentar

Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.