ActionBarCompat ListView Modal Choice Sample
Change-Id: I444108211ec35d8b9e58437c3c39d61865613d64
Signed-off-by: Chris Banes <chrisbanes@google.com>
(cherry picked from commit ff54b59b080340f3735432c61bbd671c84dbecea)
diff --git a/common/src/com/example/android/common/actionbarcompat/MultiSelectionUtil.java b/common/src/com/example/android/common/actionbarcompat/MultiSelectionUtil.java
new file mode 100644
index 0000000..482f6ed
--- /dev/null
+++ b/common/src/com/example/android/common/actionbarcompat/MultiSelectionUtil.java
@@ -0,0 +1,293 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.common.actionbarcompat;
+
+import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.view.ActionMode;
+import android.util.Pair;
+import android.util.SparseBooleanArray;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AbsListView;
+import android.widget.Adapter;
+import android.widget.AdapterView;
+import android.widget.ListView;
+
+import java.util.HashSet;
+
+/**
+ * Utilities for handling multiple selection in list views. Contains functionality similar to {@link
+ * AbsListView#CHOICE_MODE_MULTIPLE_MODAL} which works with {@link ActionBarActivity} and
+ * backward-compatible action bars.
+ */
+public class MultiSelectionUtil {
+
+ /**
+ * Attach a Controller to the given <code>listView</code>, <code>activity</code>
+ * and <code>listener</code>.
+ *
+ * @param listView ListView which displays {@link android.widget.Checkable} items.
+ * @param activity Activity which contains the ListView.
+ * @param listener Listener that will manage the selection mode.
+ * @return the attached Controller instance.
+ */
+ public static Controller attachMultiSelectionController(final ListView listView,
+ final ActionBarActivity activity, final MultiChoiceModeListener listener) {
+ return new Controller(listView, activity, listener);
+ }
+
+ /**
+ * Class which provides functionality similar to {@link AbsListView#CHOICE_MODE_MULTIPLE_MODAL}
+ * for the {@link ListView} provided to it. A
+ * {@link android.widget.AdapterView.OnItemLongClickListener} is set on the ListView so that
+ * when an item is long-clicked an ActionBarCompat Action Mode is started. Once started, a
+ * {@link android.widget.AdapterView.OnItemClickListener} is set so that an item click toggles
+ * that item's checked state.
+ */
+ public static class Controller {
+
+ private final ListView mListView;
+ private final ActionBarActivity mActivity;
+ private final MultiChoiceModeListener mListener;
+ private final Callbacks mCallbacks;
+
+ // Current Action Mode (if there is one)
+ private ActionMode mActionMode;
+
+ // Keeps record of any items that should be checked on the next action mode creation
+ private HashSet<Pair<Integer, Long>> mItemsToCheck;
+
+ // Reference to the replace OnItemClickListener (so it can be restored later)
+ private AdapterView.OnItemClickListener mOldItemClickListener;
+
+ private final Runnable mSetChoiceModeNoneRunnable = new Runnable() {
+ @Override
+ public void run() {
+ mListView.setChoiceMode(AbsListView.CHOICE_MODE_NONE);
+ }
+ };
+
+ private Controller(ListView listView, ActionBarActivity activity,
+ MultiChoiceModeListener listener) {
+ mListView = listView;
+ mActivity = activity;
+ mListener = listener;
+ mCallbacks = new Callbacks();
+
+ // We set ourselves as the OnItemLongClickListener so we know when to start
+ // an Action Mode
+ listView.setOnItemLongClickListener(mCallbacks);
+ }
+
+ /**
+ * Finish the current Action Mode (if there is one).
+ */
+ public void finish() {
+ if (mActionMode != null) {
+ mActionMode.finish();
+ }
+ }
+
+ /**
+ * This method should be called from your {@link ActionBarActivity} or
+ * {@link android.support.v4.app.Fragment Fragment} to allow the controller to restore any
+ * instance state.
+ *
+ * @param savedInstanceState - The state passed to your Activity or Fragment.
+ */
+ public void restoreInstanceState(Bundle savedInstanceState) {
+ if (savedInstanceState != null) {
+ long[] checkedIds = savedInstanceState.getLongArray(getStateKey());
+ if (checkedIds != null && checkedIds.length > 0) {
+ HashSet<Long> idsToCheckOnRestore = new HashSet<Long>();
+ for (long id : checkedIds) {
+ idsToCheckOnRestore.add(id);
+ }
+ tryRestoreInstanceState(idsToCheckOnRestore);
+ }
+ }
+ }
+
+ /**
+ * This method should be called from
+ * {@link ActionBarActivity#onSaveInstanceState(android.os.Bundle)} or
+ * {@link android.support.v4.app.Fragment#onSaveInstanceState(android.os.Bundle)
+ * Fragment.onSaveInstanceState(Bundle)} to allow the controller to save its instance
+ * state.
+ *
+ * @param outState - The state passed to your Activity or Fragment.
+ */
+ public void saveInstanceState(Bundle outState) {
+ if (mActionMode != null && mListView.getAdapter().hasStableIds()) {
+ outState.putLongArray(getStateKey(), mListView.getCheckedItemIds());
+ }
+ }
+
+ // Internal utility methods
+
+ private String getStateKey() {
+ return MultiSelectionUtil.class.getSimpleName() + "_" + mListView.getId();
+ }
+
+ private void tryRestoreInstanceState(HashSet<Long> idsToCheckOnRestore) {
+ if (idsToCheckOnRestore == null || mListView.getAdapter() == null) {
+ return;
+ }
+
+ boolean idsFound = false;
+ Adapter adapter = mListView.getAdapter();
+ for (int pos = adapter.getCount() - 1; pos >= 0; pos--) {
+ if (idsToCheckOnRestore.contains(adapter.getItemId(pos))) {
+ idsFound = true;
+ if (mItemsToCheck == null) {
+ mItemsToCheck = new HashSet<Pair<Integer, Long>>();
+ }
+ mItemsToCheck.add(new Pair<Integer, Long>(pos, adapter.getItemId(pos)));
+ }
+ }
+
+ if (idsFound) {
+ // We found some IDs that were checked. Let's now restore the multi-selection
+ // state.
+ mActionMode = mActivity.startSupportActionMode(mCallbacks);
+ }
+ }
+
+ /**
+ * This class encapsulates all of the callbacks necessary for the controller class.
+ */
+ final class Callbacks implements ActionMode.Callback, AdapterView.OnItemClickListener,
+ AdapterView.OnItemLongClickListener {
+
+ @Override
+ public final boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
+ if (mListener.onCreateActionMode(actionMode, menu)) {
+ mActionMode = actionMode;
+ // Keep a reference to the existing OnItemClickListener so we can restore it
+ mOldItemClickListener = mListView.getOnItemClickListener();
+
+ // Set-up the ListView to emulate CHOICE_MODE_MULTIPLE_MODAL
+ mListView.setOnItemClickListener(this);
+ mListView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE);
+ mListView.removeCallbacks(mSetChoiceModeNoneRunnable);
+
+ // If there are some items to check, do it now
+ if (mItemsToCheck != null) {
+ for (Pair<Integer, Long> posAndId : mItemsToCheck) {
+ mListView.setItemChecked(posAndId.first, true);
+ // Notify the listener that the item has been checked
+ mListener.onItemCheckedStateChanged(mActionMode, posAndId.first,
+ posAndId.second, true);
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
+ // Proxy listener
+ return mListener.onPrepareActionMode(actionMode, menu);
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
+ // Proxy listener
+ return mListener.onActionItemClicked(actionMode, menuItem);
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode actionMode) {
+ mListener.onDestroyActionMode(actionMode);
+
+ // Clear all the checked items
+ SparseBooleanArray checkedPositions = mListView.getCheckedItemPositions();
+ if (checkedPositions != null) {
+ for (int i = 0; i < checkedPositions.size(); i++) {
+ mListView.setItemChecked(checkedPositions.keyAt(i), false);
+ }
+ }
+
+ // Restore the original onItemClickListener
+ mListView.setOnItemClickListener(mOldItemClickListener);
+
+ // Clear the Action Mode
+ mActionMode = null;
+
+ // Reset the ListView's Choice Mode
+ mListView.post(mSetChoiceModeNoneRunnable);
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
+ // Check to see what the new checked state is, and then notify the listener
+ final boolean checked = mListView.isItemChecked(position);
+ mListener.onItemCheckedStateChanged(mActionMode, position, id, checked);
+
+ boolean hasCheckedItem = checked;
+
+ // Check to see if we have any checked items
+ if (!hasCheckedItem) {
+ SparseBooleanArray checkedItemPositions = mListView.getCheckedItemPositions();
+ if (checkedItemPositions != null) {
+ // Iterate through the SparseBooleanArray to see if there is a checked item
+ int i = 0;
+ while (!hasCheckedItem && i < checkedItemPositions.size()) {
+ hasCheckedItem = checkedItemPositions.valueAt(i++);
+ }
+ }
+ }
+
+ // If we don't have any checked items, finish the action mode
+ if (!hasCheckedItem) {
+ mActionMode.finish();
+ }
+ }
+
+ @Override
+ public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position,
+ long id) {
+ // If we already have an action mode started return false
+ // (onItemClick will be called anyway)
+ if (mActionMode != null) {
+ return false;
+ }
+
+ mItemsToCheck = new HashSet<Pair<Integer, Long>>();
+ mItemsToCheck.add(new Pair<Integer, Long>(position, id));
+ mActionMode = mActivity.startSupportActionMode(this);
+ return true;
+ }
+ }
+ }
+
+ /**
+ * @see android.widget.AbsListView.MultiChoiceModeListener
+ */
+ public static interface MultiChoiceModeListener extends ActionMode.Callback {
+
+ /**
+ * @see android.widget.AbsListView.MultiChoiceModeListener#onItemCheckedStateChanged(
+ *android.view.ActionMode, int, long, boolean)
+ */
+ public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
+ boolean checked);
+ }
+}
diff --git a/common/src/com/example/android/common/dummydata/Cheeses.java b/common/src/com/example/android/common/dummydata/Cheeses.java
new file mode 100644
index 0000000..a386e68
--- /dev/null
+++ b/common/src/com/example/android/common/dummydata/Cheeses.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.common.dummydata;
+
+import java.util.ArrayList;
+
+/**
+ * Dummy data.
+ */
+public class Cheeses {
+ static final String[] CHEESES = {
+ "Abbaye de Belloc", "Abbaye du Mont des Cats", "Abertam", "Abondance", "Ackawi",
+ "Acorn", "Adelost", "Affidelice au Chablis", "Afuega'l Pitu", "Airag", "Airedale",
+ "Aisy Cendre", "Allgauer Emmentaler", "Alverca", "Ambert", "American Cheese",
+ "Ami du Chambertin", "Anejo Enchilado", "Anneau du Vic-Bilh", "Anthoriro", "Appenzell",
+ "Aragon", "Ardi Gasna", "Ardrahan", "Armenian String", "Aromes au Gene de Marc",
+ "Asadero", "Asiago", "Aubisque Pyrenees", "Autun", "Avaxtskyr", "Baby Swiss",
+ "Babybel", "Baguette Laonnaise", "Bakers", "Baladi", "Balaton", "Bandal", "Banon",
+ "Barry's Bay Cheddar", "Basing", "Basket Cheese", "Bath Cheese", "Bavarian Bergkase",
+ "Baylough", "Beaufort", "Beauvoorde", "Beenleigh Blue", "Beer Cheese", "Bel Paese",
+ "Bergader", "Bergere Bleue", "Berkswell", "Beyaz Peynir", "Bierkase", "Bishop Kennedy",
+ "Blarney", "Bleu d'Auvergne", "Bleu de Gex", "Bleu de Laqueuille",
+ "Bleu de Septmoncel", "Bleu Des Causses", "Blue", "Blue Castello", "Blue Rathgore",
+ "Blue Vein (Australian)", "Blue Vein Cheeses", "Bocconcini", "Bocconcini (Australian)",
+ "Boeren Leidenkaas", "Bonchester", "Bosworth", "Bougon", "Boule Du Roves",
+ "Boulette d'Avesnes", "Boursault", "Boursin", "Bouyssou", "Bra", "Braudostur",
+ "Breakfast Cheese", "Brebis du Lavort", "Brebis du Lochois", "Brebis du Puyfaucon",
+ "Bresse Bleu", "Brick", "Brie", "Brie de Meaux", "Brie de Melun", "Brillat-Savarin",
+ "Brin", "Brin d' Amour", "Brin d'Amour", "Brinza (Burduf Brinza)",
+ "Briquette de Brebis", "Briquette du Forez", "Broccio", "Broccio Demi-Affine",
+ "Brousse du Rove", "Bruder Basil", "Brusselae Kaas (Fromage de Bruxelles)", "Bryndza",
+ "Buchette d'Anjou", "Buffalo", "Burgos", "Butte", "Butterkase", "Button (Innes)",
+ "Buxton Blue", "Cabecou", "Caboc", "Cabrales", "Cachaille", "Caciocavallo", "Caciotta",
+ "Caerphilly", "Cairnsmore", "Calenzana", "Cambazola", "Camembert de Normandie",
+ "Canadian Cheddar", "Canestrato", "Cantal", "Caprice des Dieux", "Capricorn Goat",
+ "Capriole Banon", "Carre de l'Est", "Casciotta di Urbino", "Cashel Blue", "Castellano",
+ "Castelleno", "Castelmagno", "Castelo Branco", "Castigliano", "Cathelain",
+ "Celtic Promise", "Cendre d'Olivet", "Cerney", "Chabichou", "Chabichou du Poitou",
+ "Chabis de Gatine", "Chaource", "Charolais", "Chaumes", "Cheddar",
+ "Cheddar Clothbound", "Cheshire", "Chevres", "Chevrotin des Aravis", "Chontaleno",
+ "Civray", "Coeur de Camembert au Calvados", "Coeur de Chevre", "Colby", "Cold Pack",
+ "Comte", "Coolea", "Cooleney", "Coquetdale", "Corleggy", "Cornish Pepper",
+ "Cotherstone", "Cotija", "Cottage Cheese", "Cottage Cheese (Australian)",
+ "Cougar Gold", "Coulommiers", "Coverdale", "Crayeux de Roncq", "Cream Cheese",
+ "Cream Havarti", "Crema Agria", "Crema Mexicana", "Creme Fraiche", "Crescenza",
+ "Croghan", "Crottin de Chavignol", "Crottin du Chavignol", "Crowdie", "Crowley",
+ "Cuajada", "Curd", "Cure Nantais", "Curworthy", "Cwmtawe Pecorino",
+ "Cypress Grove Chevre", "Danablu (Danish Blue)", "Danbo", "Danish Fontina",
+ "Daralagjazsky", "Dauphin", "Delice des Fiouves", "Denhany Dorset Drum", "Derby",
+ "Dessertnyj Belyj", "Devon Blue", "Devon Garland", "Dolcelatte", "Doolin",
+ "Doppelrhamstufel", "Dorset Blue Vinney", "Double Gloucester", "Double Worcester",
+ "Dreux a la Feuille", "Dry Jack", "Duddleswell", "Dunbarra", "Dunlop", "Dunsyre Blue",
+ "Duroblando", "Durrus", "Dutch Mimolette (Commissiekaas)", "Edam", "Edelpilz",
+ "Emental Grand Cru", "Emlett", "Emmental", "Epoisses de Bourgogne", "Esbareich",
+ "Esrom", "Etorki", "Evansdale Farmhouse Brie", "Evora De L'Alentejo", "Exmoor Blue",
+ "Explorateur", "Feta", "Feta (Australian)", "Figue", "Filetta", "Fin-de-Siecle",
+ "Finlandia Swiss", "Finn", "Fiore Sardo", "Fleur du Maquis", "Flor de Guia",
+ "Flower Marie", "Folded", "Folded cheese with mint", "Fondant de Brebis",
+ "Fontainebleau", "Fontal", "Fontina Val d'Aosta", "Formaggio di capra", "Fougerus",
+ "Four Herb Gouda", "Fourme d' Ambert", "Fourme de Haute Loire", "Fourme de Montbrison",
+ "Fresh Jack", "Fresh Mozzarella", "Fresh Ricotta", "Fresh Truffles", "Fribourgeois",
+ "Friesekaas", "Friesian", "Friesla", "Frinault", "Fromage a Raclette", "Fromage Corse",
+ "Fromage de Montagne de Savoie", "Fromage Frais", "Fruit Cream Cheese",
+ "Frying Cheese", "Fynbo", "Gabriel", "Galette du Paludier", "Galette Lyonnaise",
+ "Galloway Goat's Milk Gems", "Gammelost", "Gaperon a l'Ail", "Garrotxa", "Gastanberra",
+ "Geitost", "Gippsland Blue", "Gjetost", "Gloucester", "Golden Cross", "Gorgonzola",
+ "Gornyaltajski", "Gospel Green", "Gouda", "Goutu", "Gowrie", "Grabetto", "Graddost",
+ "Grafton Village Cheddar", "Grana", "Grana Padano", "Grand Vatel",
+ "Grataron d' Areches", "Gratte-Paille", "Graviera", "Greuilh", "Greve",
+ "Gris de Lille", "Gruyere", "Gubbeen", "Guerbigny", "Halloumi",
+ "Halloumy (Australian)", "Haloumi-Style Cheese", "Harbourne Blue", "Havarti",
+ "Heidi Gruyere", "Hereford Hop", "Herrgardsost", "Herriot Farmhouse", "Herve",
+ "Hipi Iti", "Hubbardston Blue Cow", "Hushallsost", "Iberico", "Idaho Goatster",
+ "Idiazabal", "Il Boschetto al Tartufo", "Ile d'Yeu", "Isle of Mull", "Jarlsberg",
+ "Jermi Tortes", "Jibneh Arabieh", "Jindi Brie", "Jubilee Blue", "Juustoleipa",
+ "Kadchgall", "Kaseri", "Kashta", "Kefalotyri", "Kenafa", "Kernhem", "Kervella Affine",
+ "Kikorangi", "King Island Cape Wickham Brie", "King River Gold", "Klosterkaese",
+ "Knockalara", "Kugelkase", "L'Aveyronnais", "L'Ecir de l'Aubrac", "La Taupiniere",
+ "La Vache Qui Rit", "Laguiole", "Lairobell", "Lajta", "Lanark Blue", "Lancashire",
+ "Langres", "Lappi", "Laruns", "Lavistown", "Le Brin", "Le Fium Orbo", "Le Lacandou",
+ "Le Roule", "Leafield", "Lebbene", "Leerdammer", "Leicester", "Leyden", "Limburger",
+ "Lincolnshire Poacher", "Lingot Saint Bousquet d'Orb", "Liptauer", "Little Rydings",
+ "Livarot", "Llanboidy", "Llanglofan Farmhouse", "Loch Arthur Farmhouse",
+ "Loddiswell Avondale", "Longhorn", "Lou Palou", "Lou Pevre", "Lyonnais", "Maasdam",
+ "Macconais", "Mahoe Aged Gouda", "Mahon", "Malvern", "Mamirolle", "Manchego",
+ "Manouri", "Manur", "Marble Cheddar", "Marbled Cheeses", "Maredsous", "Margotin",
+ "Maribo", "Maroilles", "Mascares", "Mascarpone", "Mascarpone (Australian)",
+ "Mascarpone Torta", "Matocq", "Maytag Blue", "Meira", "Menallack Farmhouse",
+ "Menonita", "Meredith Blue", "Mesost", "Metton (Cancoillotte)", "Meyer Vintage Gouda",
+ "Mihalic Peynir", "Milleens", "Mimolette", "Mine-Gabhar", "Mini Baby Bells", "Mixte",
+ "Molbo", "Monastery Cheeses", "Mondseer", "Mont D'or Lyonnais", "Montasio",
+ "Monterey Jack", "Monterey Jack Dry", "Morbier", "Morbier Cru de Montagne",
+ "Mothais a la Feuille", "Mozzarella", "Mozzarella (Australian)",
+ "Mozzarella di Bufala", "Mozzarella Fresh, in water", "Mozzarella Rolls", "Munster",
+ "Murol", "Mycella", "Myzithra", "Naboulsi", "Nantais", "Neufchatel",
+ "Neufchatel (Australian)", "Niolo", "Nokkelost", "Northumberland", "Oaxaca",
+ "Olde York", "Olivet au Foin", "Olivet Bleu", "Olivet Cendre",
+ "Orkney Extra Mature Cheddar", "Orla", "Oschtjepka", "Ossau Fermier", "Ossau-Iraty",
+ "Oszczypek", "Oxford Blue", "P'tit Berrichon", "Palet de Babligny", "Paneer", "Panela",
+ "Pannerone", "Pant ys Gawn", "Parmesan (Parmigiano)", "Parmigiano Reggiano",
+ "Pas de l'Escalette", "Passendale", "Pasteurized Processed", "Pate de Fromage",
+ "Patefine Fort", "Pave d'Affinois", "Pave d'Auge", "Pave de Chirac", "Pave du Berry",
+ "Pecorino", "Pecorino in Walnut Leaves", "Pecorino Romano", "Peekskill Pyramid",
+ "Pelardon des Cevennes", "Pelardon des Corbieres", "Penamellera", "Penbryn",
+ "Pencarreg", "Perail de Brebis", "Petit Morin", "Petit Pardou", "Petit-Suisse",
+ "Picodon de Chevre", "Picos de Europa", "Piora", "Pithtviers au Foin",
+ "Plateau de Herve", "Plymouth Cheese", "Podhalanski", "Poivre d'Ane", "Polkolbin",
+ "Pont l'Eveque", "Port Nicholson", "Port-Salut", "Postel", "Pouligny-Saint-Pierre",
+ "Pourly", "Prastost", "Pressato", "Prince-Jean", "Processed Cheddar", "Provolone",
+ "Provolone (Australian)", "Pyengana Cheddar", "Pyramide", "Quark",
+ "Quark (Australian)", "Quartirolo Lombardo", "Quatre-Vents", "Quercy Petit",
+ "Queso Blanco", "Queso Blanco con Frutas --Pina y Mango", "Queso de Murcia",
+ "Queso del Montsec", "Queso del Tietar", "Queso Fresco", "Queso Fresco (Adobera)",
+ "Queso Iberico", "Queso Jalapeno", "Queso Majorero", "Queso Media Luna",
+ "Queso Para Frier", "Queso Quesadilla", "Rabacal", "Raclette", "Ragusano", "Raschera",
+ "Reblochon", "Red Leicester", "Regal de la Dombes", "Reggianito", "Remedou",
+ "Requeson", "Richelieu", "Ricotta", "Ricotta (Australian)", "Ricotta Salata", "Ridder",
+ "Rigotte", "Rocamadour", "Rollot", "Romano", "Romans Part Dieu", "Roncal", "Roquefort",
+ "Roule", "Rouleau De Beaulieu", "Royalp Tilsit", "Rubens", "Rustinu", "Saaland Pfarr",
+ "Saanenkaese", "Saga", "Sage Derby", "Sainte Maure", "Saint-Marcellin",
+ "Saint-Nectaire", "Saint-Paulin", "Salers", "Samso", "San Simon", "Sancerre",
+ "Sap Sago", "Sardo", "Sardo Egyptian", "Sbrinz", "Scamorza", "Schabzieger", "Schloss",
+ "Selles sur Cher", "Selva", "Serat", "Seriously Strong Cheddar", "Serra da Estrela",
+ "Sharpam", "Shelburne Cheddar", "Shropshire Blue", "Siraz", "Sirene", "Smoked Gouda",
+ "Somerset Brie", "Sonoma Jack", "Sottocenare al Tartufo", "Soumaintrain",
+ "Sourire Lozerien", "Spenwood", "Sraffordshire Organic", "St. Agur Blue Cheese",
+ "Stilton", "Stinking Bishop", "String", "Sussex Slipcote", "Sveciaost", "Swaledale",
+ "Sweet Style Swiss", "Swiss", "Syrian (Armenian String)", "Tala", "Taleggio", "Tamie",
+ "Tasmania Highland Chevre Log", "Taupiniere", "Teifi", "Telemea", "Testouri",
+ "Tete de Moine", "Tetilla", "Texas Goat Cheese", "Tibet", "Tillamook Cheddar",
+ "Tilsit", "Timboon Brie", "Toma", "Tomme Brulee", "Tomme d'Abondance",
+ "Tomme de Chevre", "Tomme de Romans", "Tomme de Savoie", "Tomme des Chouans", "Tommes",
+ "Torta del Casar", "Toscanello", "Touree de L'Aubier", "Tourmalet",
+ "Trappe (Veritable)", "Trois Cornes De Vendee", "Tronchon", "Trou du Cru", "Truffe",
+ "Tupi", "Turunmaa", "Tymsboro", "Tyn Grug", "Tyning", "Ubriaco", "Ulloa",
+ "Vacherin-Fribourgeois", "Valencay", "Vasterbottenost", "Venaco", "Vendomois",
+ "Vieux Corse", "Vignotte", "Vulscombe", "Waimata Farmhouse Blue",
+ "Washed Rind Cheese (Australian)", "Waterloo", "Weichkaese", "Wellington",
+ "Wensleydale", "White Stilton", "Whitestone Farmhouse", "Wigmore", "Woodside Cabecou",
+ "Xanadu", "Xynotyro", "Yarg Cornish", "Yarra Valley Pyramid", "Yorkshire Blue",
+ "Zamorano", "Zanetti Grana Padano", "Zanetti Parmigiano Reggiano"
+ };
+
+ public static ArrayList<String> asList() {
+ ArrayList<String> items = new ArrayList<String>();
+ for (int i = 0, z = CHEESES.length ; i < z ; i++) {
+ items.add(CHEESES[i]);
+ }
+ return items;
+ }
+}
\ No newline at end of file
diff --git a/ui/actionbarcompat/ListViewModalSelect/big_icon.png b/ui/actionbarcompat/ListViewModalSelect/big_icon.png
new file mode 100644
index 0000000..0f47486
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/big_icon.png
Binary files differ
diff --git a/ui/actionbarcompat/ListViewModalSelect/build.gradle b/ui/actionbarcompat/ListViewModalSelect/build.gradle
new file mode 100644
index 0000000..b99b102
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/build.gradle
@@ -0,0 +1,16 @@
+apply plugin: 'android'
+
+dependencies {
+ compile "com.android.support:support-v4:18.0.+"
+ compile "com.android.support:appcompat-v7:18.0.+"
+}
+
+android {
+ compileSdkVersion 17
+ buildToolsVersion "17.0.0"
+
+ defaultConfig {
+ minSdkVersion 7
+ targetSdkVersion 16
+ }
+}
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/AndroidManifest.xml b/ui/actionbarcompat/ListViewModalSelect/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..1ca1c5d
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/AndroidManifest.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.actionbarcompat.listviewmodalselect"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <!--
+ ActionBarCompat provides an Action Bar from API v7 onwards
+ -->
+ <uses-sdk
+ android:minSdkVersion="7"
+ android:targetSdkVersion="17" />
+
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/Theme.AppCompat"
+ android:allowBackup="true">
+
+ <activity
+ android:name=".MainActivity">
+ <!-- Launcher Intent filter -->
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ </application>
+
+</manifest>
\ No newline at end of file
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-hdpi/ic_launcher.png b/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..a3d6711
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-mdpi/ic_launcher.png b/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..f488bbc
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..0651b33
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..ac8a199
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable/background_checked.xml b/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable/background_checked.xml
new file mode 100644
index 0000000..9d8bef3
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/res/drawable/background_checked.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_checked="true" android:drawable="@color/translucent_blue" />
+ <item android:drawable="@android:color/transparent" />
+</selector>
\ No newline at end of file
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/res/layout/activity_main.xml b/ui/actionbarcompat/ListViewModalSelect/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..456cd19
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/res/layout/activity_main.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <fragment
+ android:id="@+id/frag_app_list"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:name="com.example.android.actionbarcompat.listviewmodalselect.CheeseListFragment" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/intro_message"
+ android:padding="16dp"
+ android:textAppearance="?android:textAppearanceMedium"
+ android:lineSpacingMultiplier="1.1"
+ android:background="#fb3"/>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/res/layout/simple_selectable_list_item.xml b/ui/actionbarcompat/ListViewModalSelect/src/main/res/layout/simple_selectable_list_item.xml
new file mode 100644
index 0000000..5f82f4b
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/res/layout/simple_selectable_list_item.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ The layout which is used in our ListView items. We use a CheckedTextView so we can
+ simulate the activated state (added in available from API v11) with the checked
+ state, which is available from API v1.
+-->
+<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@android:id/text1"
+ android:layout_width="match_parent"
+ android:layout_height="?android:attr/listPreferredItemHeight"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:gravity="center_vertical"
+ android:background="@drawable/background_checked"
+ android:paddingLeft="6dip"
+ android:paddingRight="9dip"/>
\ No newline at end of file
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/res/menu/context_cheeses.xml b/ui/actionbarcompat/ListViewModalSelect/src/main/res/menu/context_cheeses.xml
new file mode 100644
index 0000000..e845a4d
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/res/menu/context_cheeses.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ As we're using ActionBarCompat, any action item attributes come from ActionBarCompat's XML
+ namespace instead of the android namespace. Here we've added a new support namespace added to
+ the menu element allowing us to use the 'showAsAction' attribute in a backwards compatible way.
+ Any other action item attributes used should be referenced from this namespace too
+ (actionProviderClass, actionViewClass, actionLayout).
+-->
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:support="http://schemas.android.com/apk/res-auto">
+
+ <item
+ android:id="@+id/menu_remove"
+ android:title="@string/menu_remove"
+ support:showAsAction="ifRoom"/>
+
+</menu>
\ No newline at end of file
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/res/values/colors.xml b/ui/actionbarcompat/ListViewModalSelect/src/main/res/values/colors.xml
new file mode 100644
index 0000000..c4e8b3a
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/res/values/colors.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+
+ <!-- A translucent holo blue -->
+ <color name="translucent_blue">#9033B5E5</color>
+
+</resources>
\ No newline at end of file
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/res/values/strings.xml b/ui/actionbarcompat/ListViewModalSelect/src/main/res/values/strings.xml
new file mode 100644
index 0000000..1987fab
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/res/values/strings.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+
+ <string name="app_name">ABC ListView Modal</string>
+ <string name="intro_message">This sample demonstrates how to provide a
+ <em>MULTIPLE_MODAL</em> ListView choice mode, compatible from API v7.
+ </string>
+ <string name="menu_remove">Remove</string>
+
+</resources>
\ No newline at end of file
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/src/com/example/android/actionbarcompat/listviewmodalselect/CheeseListFragment.java b/ui/actionbarcompat/ListViewModalSelect/src/main/src/com/example/android/actionbarcompat/listviewmodalselect/CheeseListFragment.java
new file mode 100644
index 0000000..2ea9638
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/src/com/example/android/actionbarcompat/listviewmodalselect/CheeseListFragment.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.android.actionbarcompat.listviewmodalselect;
+
+import com.example.android.common.actionbarcompat.MultiSelectionUtil;
+import com.example.android.common.dummydata.Cheeses;
+
+import android.os.Bundle;
+import android.support.v4.app.ListFragment;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.view.ActionMode;
+import android.util.SparseBooleanArray;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.ArrayAdapter;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * This ListFragment displays a list of cheeses, allowing the user to select multiple items
+ * in a modal selection mode. In this example, the user can remove multiple items via the displayed
+ * action mode.
+ */
+public class CheeseListFragment extends ListFragment {
+
+ // ArrayList containing the cheese name Strings
+ private ArrayList<String> mItems;
+
+ // The Controller which provides CHOICE_MODE_MULTIPLE_MODAL-like functionality
+ private MultiSelectionUtil.Controller mMultiSelectController;
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ // The items which will be displayed
+ mItems = Cheeses.asList();
+
+ // Set the ListAdapter so that the ListView displays the items
+ setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.simple_selectable_list_item,
+ android.R.id.text1, mItems));
+
+ // BEGIN_INCLUDE(attach_controller)
+ // Attach a MultiSelectionUtil.Controller to the ListView, giving it an instance of
+ // ModalChoiceListener (see below)
+ mMultiSelectController = MultiSelectionUtil
+ .attachMultiSelectionController(getListView(), (ActionBarActivity) getActivity(),
+ new ModalChoiceListener());
+
+ // Allow the Controller to restore itself
+ mMultiSelectController.restoreInstanceState(savedInstanceState);
+ // END_INCLUDE(attach_controller)
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+
+ // BEGIN_INCLUDE(save_instance)
+ // Allow the Controller to save it's instance state so that any checked items are
+ // stored
+ if (mMultiSelectController != null) {
+ mMultiSelectController.saveInstanceState(outState);
+ }
+ // END_INCLUDE(save_instance)
+ }
+
+ /**
+ * The listener which is provided to MultiSelectionUtil to handle any multi-selection actions.
+ * It is responsible for providing the menu to display on the action mode, and handling any
+ * action item clicks.
+ */
+ private class ModalChoiceListener implements MultiSelectionUtil.MultiChoiceModeListener {
+
+ @Override
+ public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
+ boolean checked) {
+ }
+
+ @Override
+ public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
+ // Inflate the menu resource (res/menu/context_cheeses.xml) which will be displayed
+ // in the action mode
+ actionMode.getMenuInflater().inflate(R.menu.context_cheeses, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
+ // We switch on the menu item's id, so we know which is clicked
+ switch (menuItem.getItemId()) {
+
+ // Our item with the menu_remove ID is used to remove the item(s) from the list.
+ // Here we retrieve which positions are currently checked, then iterate through the
+ // list and remove the checked items. Once finished we notify the adapter to update
+ // the ListView contents and finish the action mode.
+ case R.id.menu_remove:
+ // Retrieve which positions are currently checked
+ final ListView listView = getListView();
+ SparseBooleanArray checkedPositions = listView.getCheckedItemPositions();
+
+ // Check to see if there are any checked items
+ if (checkedPositions.size() == 0) {
+ return false;
+ }
+
+ // Iterate through the items and remove any which are checked
+ final Iterator<String> iterator = mItems.iterator();
+ int i = 0;
+ while (iterator.hasNext()) {
+ // Call next() so that the iterator index moves
+ iterator.next();
+
+ // Remove the item if it is checked (and increment position)
+ if (checkedPositions.get(i++)) {
+ iterator.remove();
+ }
+ }
+
+ // Clear the ListView's checked items
+ listView.clearChoices();
+
+ // Finally, notify the adapter so that it updates the ListView
+ ((BaseAdapter) getListAdapter()).notifyDataSetChanged();
+
+ // As we're removing all of checked items, we'll close the action mode
+ actionMode.finish();
+
+ // We return true to signify that we have handled the action item click
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode actionMode) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/ui/actionbarcompat/ListViewModalSelect/src/main/src/com/example/android/actionbarcompat/listviewmodalselect/MainActivity.java b/ui/actionbarcompat/ListViewModalSelect/src/main/src/com/example/android/actionbarcompat/listviewmodalselect/MainActivity.java
new file mode 100644
index 0000000..72afc56
--- /dev/null
+++ b/ui/actionbarcompat/ListViewModalSelect/src/main/src/com/example/android/actionbarcompat/listviewmodalselect/MainActivity.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.actionbarcompat.listviewmodalselect;
+
+import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+
+/**
+ * This sample shows you how a provide a ListView which allows the user to select multiple items
+ * in a modal selection mode with ActionBarCompat, backwards compatible to API v7.
+ * <p>
+ * This Activity extends from {@link ActionBarActivity}, which provides all of the function
+ * necessary to display a compatible Action Bar on devices running Android v2.1+.
+ * <p>
+ * The interesting part of this sample is in {@link CheeseListFragment}.
+ */
+public class MainActivity extends ActionBarActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Set content view (which contains a CheeseListFragment)
+ setContentView(R.layout.activity_main);
+ }
+
+}
\ No newline at end of file