Simple List single choice : ListActivity « UI « Android






Simple List single choice

   

package app.test;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Test extends Activity {
  ListView listView;
  private String[] data = { "1", "2","3", "4", "5","6", "7","8" };
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        listView = new ListView(this);
//    listView.setAdapter(new ArrayAdapter<String>(this,
//        android.R.layout.simple_list_item_1, data));
    listView.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_single_choice, data));  
        listView.setItemsCanFocus(true);
        listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    setContentView(listView);
    }
}

   
    
    
  








Related examples in the same category

1.A list view example where the data for the list comes from an array of strings.
2.A list view example where the data comes from a cursor.
3.Using ListActivity
4.SimpleCursorAdapter and ListActivity
5.Get ListActivity selected index
6.Multi-column ListActivity
7.A list view example with separators.
8.List item click event
9.Dynamic List item
10.Self Wrapper for List
11.Static text for List view
12.List selection event
13.To do list app
14.Scale listener
15.Weather List Widget
16.Demonstrates expandable lists backed by Cursors
17.Demonstrates expandable lists backed by a Simple Map-based adapter
18.Demonstrates the using a list view in transcript mode
19.Demonstrates how a list can avoid expensive operations during scrolls or flings.
20.Demonstrates how to write an efficient list adapter.
21.A list view where the last item the user clicked is placed in the "activated" state, causing its background to highlight.
22.Calculate the minimum and maximum values out of a list of doubles.
23.Bounded Linked List
24.Adapter that simply returns row views from a list.
25.Diary app