1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.example.android.apis.view; 18 19 import android.app.ListActivity; 20 import android.os.Bundle; 21 import android.widget.ArrayAdapter; 22 import android.widget.ListView; 23 24 /** 25 * This example shows how to use choice mode on a list. This list is 26 * in CHOICE_MODE_SINGLE mode, which means the items behave like 27 * checkboxes. 28 */ 29 public class List10 extends ListActivity { 30 31 @Override 32 public void onCreate(Bundle savedInstanceState) { 33 super.onCreate(savedInstanceState); 34 35 setListAdapter(new ArrayAdapter<String>(this, 36 android.R.layout.simple_list_item_single_choice, GENRES)); 37 38 final ListView listView = getListView(); 39 40 listView.setItemsCanFocus(false); 41 listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); 42 } 43 44 45 private static final String[] GENRES = new String[] { 46 "Action", "Adventure", "Animation", "Children", "Comedy", "Documentary", "Drama", 47 "Foreign", "History", "Independent", "Romance", "Sci-Fi", "Television", "Thriller" 48 }; 49 } 50