• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Android Samples


Commit MetaInfo

修訂28a449735a46e4ddbc05aa1104e190dc586fa7ff (tree)
時間2013-05-10 15:46:36
作者Masahiko, SAWAI <say@user...>
CommiterMasahiko, SAWAI

Log Message

actionmode-listview-in-fragment を追加

Change Summary

差異

--- /dev/null
+++ b/actionmode-listview-in-fragment/AndroidManifest.xml
@@ -0,0 +1,23 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+ package="com.example.hello.android.actionmode_listview_in_fragment"
4+ android:versionCode="1"
5+ android:versionName="1.0"
6+>
7+ <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="11" />
8+
9+ <application android:label="@string/app_name">
10+ <activity android:name="UserListActivity"
11+ android:label="@string/app_name"
12+ >
13+ <intent-filter>
14+ <action android:name="android.intent.action.MAIN" />
15+ <category android:name="android.intent.category.LAUNCHER" />
16+ </intent-filter>
17+ </activity>
18+ </application>
19+
20+ <!--
21+ <uses-permission android:name="android.permission.INTERNET" />
22+ -->
23+</manifest>
--- /dev/null
+++ b/actionmode-listview-in-fragment/Makefile
@@ -0,0 +1,47 @@
1+RELEASE_PROFILE=android-hello
2+
3+all : package
4+
5+#################### build
6+
7+compile :
8+ mvn $@
9+
10+gen :
11+ mvn android:generate-sources
12+
13+package :
14+ mvn $@
15+
16+release :
17+ mvn clean && mvn -P$(RELEASE_PROFILE) package
18+
19+install :
20+ mvn $@
21+
22+deploy :
23+ mvn package android:deploy
24+
25+undeploy :
26+ mvn android:undeploy
27+
28+rebuild :
29+ mvn clean package
30+
31+redeploy :
32+ mvn clean package android:deploy
33+
34+
35+#################### emulator
36+start :
37+ mvn android:emulator-start
38+
39+stop :
40+ mvn android:emulator-stop
41+
42+#################### project
43+dist :
44+ mvn assembly:assembly
45+
46+clean :
47+ mvn $@
--- /dev/null
+++ b/actionmode-listview-in-fragment/README.txt
@@ -0,0 +1,70 @@
1+! actionmode-listview-in-fragment (API Level 11)
2+
3+Android 3.0 で ListView で複数アイテムを選択して処理を
4+実行するような仕組みとしてアクションモードというものがある。
5+
6+ListView が Fragment 内にある場合のアクションモードのサンプル。
7+実装の手順は基本的に Activity の場合と同じである。
8+
9+以下のメソッドを呼び出したうえで、ListView のアイテムをロングタップすると
10+アクションモードに入る。
11+
12+* ListView#setChoiceMode(int choideMode)
13+* ListView#setMultiChoiceModeListener(MultiChoiceModeListener listener) : void
14+
15+
16+MultiChoiceModeListener の以下のメソッドを実装することで
17+アクションモードを実現する。
18+
19+* onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) : void
20+* onCreateActionMode(ActionMode mode, Menu menu) : boolean
21+* onPrepareActionMode(ActionMode mode, Menu menu) : boolean
22+* onActionItemClicked(ActionMode mode, MenuItem item) : boolean
23+* onDestroyActionMode(ActionMode mode) : void
24+
25+onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) : void
26+は各項目の選択状態が変わった際に呼ばれるコールバック。
27+
28+onCreateActionMode(ActionMode mode, Menu menu) : boolean
29+はこのアクションモードに入った際に呼ばれるコールバック。
30+ここでアクションアイテムの作成やタイトルの設定などを行う。
31+ここで作成したメニューアイテムはこのアクションモード専用のものとなる。
32+
33+onPrepareActionMode(ActionMode mode, Menu menu) : boolean
34+はこのアクションモードになる直前に呼ばれるコールバック。
35+onCreateActionMode() より後でり、アクションアイテムなどの
36+各種ビューが初期化完了している事が期待できる。
37+
38+onActionItemClicked(ActionMode mode, MenuItem item) : boolean
39+はアクションアイテムがクリックした際のコールバック。
40+
41+onDestroyActionMode(ActionMode mode) : void
42+はアクションモード終了時のコールバック。
43+ActionMode#finish() を呼び出したり、左上の「×」をクリックして
44+アクションモードが終了したときに呼ばれる。
45+
46+
47+基本的な流れは、
48+onCreateActionMode(ActionMode mode, Menu menu) : boolean
49+で処理を実行するためのアクションアイテムを menu に作成して、
50+アクションアイテムがクリックされた際のリスナーである
51+onActionItemClicked(ActionMode mode, MenuItem item) : boolean
52+で実際の処理を開始する。
53+
54+
55+!! ビルドターゲット
56+
57+http://maven-android-plugin-m2site.googlecode.com/svn/plugin-info.html
58+
59+* mvn compile - アプリケーションのコンパイル
60+* mvn package - apk の作成
61+* mvn clean - ビルドファイルの削除
62+* mvn install - maven の local リポジトリにインストール
63+
64+* mvn android:deploy - エミュレータやデバイスにインストール
65+* mvn android:generate-sources
66+
67+* mvn install - アプリケーションのインストール
68+* mvn uninstall - アプリケーションのアンインストール
69+
70+
--- /dev/null
+++ b/actionmode-listview-in-fragment/pom.xml
@@ -0,0 +1,147 @@
1+<?xml version="1.0" encoding="UTF-8" ?>
2+<project
3+ xmlns="http://maven.apache.org/POM/4.0.0"
4+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
6+>
7+ <modelVersion>4.0.0</modelVersion>
8+ <groupId>com.example.hello</groupId>
9+ <artifactId>actionmode-listview-in-fragment</artifactId>
10+ <packaging>apk</packaging>
11+ <version>1.0.0</version>
12+ <name>ActionMode : ListView in Fragment</name>
13+
14+ <parent>
15+ <groupId>com.example.hello</groupId>
16+ <artifactId>android-samples</artifactId>
17+ <version>1.0.0</version>
18+ </parent>
19+
20+ <dependencies>
21+
22+ <dependency>
23+ <groupId>android</groupId>
24+ <artifactId>android</artifactId>
25+ <version>3.0_r2</version>
26+ <!--
27+ <version>1.5_r3</version>
28+ <version>1.5_r4</version>
29+ <version>1.6_r2</version>
30+ <version>2.1.2</version>
31+ <version>2.1_r1</version>
32+ <version>2.2.1</version>
33+ <version>2.3.1</version>
34+ <version>2.3.3</version>
35+ <version>4.0.1.2</version>
36+ -->
37+ <scope>provided</scope>
38+ </dependency>
39+
40+ <dependency>
41+ <groupId>junit</groupId>
42+ <artifactId>junit</artifactId>
43+ <scope>test</scope>
44+ </dependency>
45+ </dependencies>
46+
47+ <build>
48+ <sourceDirectory>src</sourceDirectory>
49+
50+ <plugins>
51+ <plugin>
52+ <groupId>com.jayway.maven.plugins.android.generation2</groupId>
53+ <artifactId>android-maven-plugin</artifactId>
54+ <configuration>
55+ <sdk>
56+ <path>${env.ANDROID_HOME}</path>
57+ <!-- <path>C:/Java/android-sdk</path> -->
58+ <platform>11</platform>
59+ </sdk>
60+ <proguard>
61+ <skip>true</skip>
62+ <config>proguard.conf</config>
63+ </proguard>
64+ <extractDuplicates>true</extractDuplicates>
65+ </configuration>
66+ <extensions>true</extensions>
67+ </plugin>
68+
69+ <!-- mvn compile -->
70+ <plugin>
71+ <groupId>org.apache.maven.plugins</groupId>
72+ <artifactId>maven-compiler-plugin</artifactId>
73+ <configuration>
74+ <source>1.5</source>
75+ <target>1.5</target>
76+ <encoding>UTF-8</encoding>
77+ </configuration>
78+ </plugin>
79+
80+ <!-- mvn assembly:assembly -->
81+ <plugin>
82+ <groupId>org.apache.maven.plugins</groupId>
83+ <artifactId>maven-assembly-plugin</artifactId>
84+ <configuration>
85+ <descriptorRefs>
86+ <!--
87+ <descriptorRef>jar-with-dependencies</descriptorRef>
88+ <descriptorRef>bin</descriptorRef>
89+ <descriptorRef>src</descriptorRef>
90+ -->
91+ <descriptorRef>project</descriptorRef>
92+ </descriptorRefs>
93+ </configuration>
94+ </plugin>
95+
96+ <!-- mvn resources:resources -->
97+ <plugin>
98+ <groupId>org.apache.maven.plugins</groupId>
99+ <artifactId>maven-resources-plugin</artifactId>
100+ <configuration>
101+ <encoding>UTF-8</encoding>
102+ </configuration>
103+ </plugin>
104+
105+ <!-- mvn site -->
106+ <plugin>
107+ <groupId>org.apache.maven.plugins</groupId>
108+ <artifactId>maven-site-plugin</artifactId>
109+ <configuration>
110+ <locales>en</locales>
111+ <inputEncoding>UTF-8</inputEncoding>
112+ <outputEncoding>UTF-8</outputEncoding>
113+
114+ <reportPlugins>
115+ <plugin>
116+ <groupId>org.apache.maven.plugins</groupId>
117+ <artifactId>maven-project-info-reports-plugin</artifactId>
118+ </plugin>
119+
120+ <!-- mvn javadoc:javadoc -->
121+ <plugin>
122+ <groupId>org.apache.maven.plugins</groupId>
123+ <artifactId>maven-javadoc-plugin</artifactId>
124+ <configuration>
125+ <charset>utf-8</charset>
126+ </configuration>
127+ </plugin>
128+ </reportPlugins>
129+ </configuration>
130+ </plugin>
131+
132+ </plugins>
133+
134+ <!-- mvn resources:resources -->
135+ <resources>
136+ <resource>
137+ <directory>res</directory>
138+ <filtering>false</filtering>
139+ <includes>
140+ <include>**/*.properties</include>
141+ </includes>
142+ </resource>
143+ </resources>
144+ </build>
145+
146+
147+</project>
--- /dev/null
+++ b/actionmode-listview-in-fragment/res/layout/simple_list.xml
@@ -0,0 +1,19 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+ android:layout_width="fill_parent"
4+ android:layout_height="fill_parent"
5+>
6+ <ListView
7+ android:id="@android:id/list"
8+ android:layout_width="fill_parent"
9+ android:layout_height="fill_parent"
10+ android:fastScrollEnabled="true"
11+ />
12+ <TextView
13+ android:id="@android:id/empty"
14+ android:layout_width="wrap_content"
15+ android:layout_height="wrap_content"
16+ android:layout_gravity="center"
17+ android:text="@string/no_data"
18+ />
19+</FrameLayout>
\ No newline at end of file
--- /dev/null
+++ b/actionmode-listview-in-fragment/res/layout/user_list_activity.xml
@@ -0,0 +1,13 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+ android:layout_width="fill_parent"
4+ android:layout_height="fill_parent"
5+ android:padding="4dip"
6+>
7+ <fragment
8+ android:id="@+id/user_list_fragment"
9+ android:name="com.example.hello.android.action_mode_fragment.UserListFragment"
10+ android:layout_width="fill_parent"
11+ android:layout_height="fill_parent"
12+ />
13+</FrameLayout>
\ No newline at end of file
--- /dev/null
+++ b/actionmode-listview-in-fragment/res/layout/user_list_fragment.xml
@@ -0,0 +1,9 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+ android:orientation="vertical"
4+ android:layout_width="fill_parent"
5+ android:layout_height="fill_parent"
6+ android:padding="4dip"
7+>
8+ <include layout="@layout/simple_list" />
9+</LinearLayout>
\ No newline at end of file
--- /dev/null
+++ b/actionmode-listview-in-fragment/res/menu/delete_menu.xml
@@ -0,0 +1,11 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<menu xmlns:android="http://schemas.android.com/apk/res/android">
3+ <item
4+ android:id="@+id/delete_menuitem"
5+ android:title="@string/delete"
6+ android:icon="@android:drawable/ic_menu_delete"
7+ android:showAsAction="ifRoom|withText"
8+ android:numericShortcut="1"
9+ android:alphabeticShortcut="d"
10+ />
11+</menu>
\ No newline at end of file
--- /dev/null
+++ b/actionmode-listview-in-fragment/res/menu/quit_menu.xml
@@ -0,0 +1,11 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<menu xmlns:android="http://schemas.android.com/apk/res/android">
3+ <item
4+ android:id="@+id/quit_menuitem"
5+ android:title="@string/quit"
6+ android:icon="@android:drawable/ic_menu_close_clear_cancel"
7+ android:showAsAction="never"
8+ android:numericShortcut="9"
9+ android:alphabeticShortcut="q"
10+ />
11+</menu>
\ No newline at end of file
--- /dev/null
+++ b/actionmode-listview-in-fragment/res/values/arrays_names.xml
@@ -0,0 +1,31 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<resources>
3+ <array name="names">
4+ <item>Alice</item>
5+ <item>Bob</item>
6+ <item>Charlie</item>
7+ <item>David</item>
8+ <item>Eve</item>
9+ <item>Frank</item>
10+ <item>George</item>
11+ <item>Harvey</item>
12+ <item>Ivan</item>
13+ <item>Justin</item>
14+ <item>Kyle</item>
15+ <item>Linda</item>
16+ <item>Matilda</item>
17+ <item>Natalia</item>
18+ <item>Oscar</item>
19+ <item>Pat</item>
20+ <item>Quincy</item>
21+ <item>Rachel</item>
22+ <item>Steave</item>
23+ <item>Trent</item>
24+ <item>Urien</item>
25+ <item>Victor</item>
26+ <item>Walter</item>
27+ <item>Xenia</item>
28+ <item>Yuriya</item>
29+ <item>Zoe</item>
30+ </array>
31+</resources>
--- /dev/null
+++ b/actionmode-listview-in-fragment/res/values/strings.xml
@@ -0,0 +1,9 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<resources>
3+ <string name="app_name">ActionMode ListView in Fragment</string>
4+ <string name="no_data">NO DATA</string>
5+
6+ <string name="delete_users">Delete Users</string>
7+ <string name="delete">Delete</string>
8+ <string name="quit">Quit</string>
9+</resources>
--- /dev/null
+++ b/actionmode-listview-in-fragment/src/com/example/hello/android/actionmode_listview_in_fragment/UserListActivity.java
@@ -0,0 +1,74 @@
1+/*
2+ * The MIT License
3+ *
4+ * Copyright 2012-2013 Masahiko, SAWAI <masahiko.sawai@gmail.com>.
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+ * THE SOFTWARE.
23+ */
24+package com.example.hello.android.actionmode_listview_in_fragment;
25+
26+import android.app.Activity;
27+import android.os.Bundle;
28+import android.util.Log;
29+import android.view.Menu;
30+import android.view.MenuInflater;
31+import android.view.MenuItem;
32+
33+public class UserListActivity extends Activity
34+{
35+
36+ private static final String LOG_TAG = "XXX";
37+
38+ @Override
39+ public void onCreate(Bundle savedInstanceState)
40+ {
41+ Log.v(LOG_TAG, "onCreate() : Hello");
42+
43+ super.onCreate(savedInstanceState);
44+ setContentView(R.layout.user_list_activity);
45+
46+ Log.v(LOG_TAG, "onCreate() : Bye");
47+ }
48+
49+ @Override
50+ public boolean onCreateOptionsMenu(Menu menu)
51+ {
52+ MenuInflater menuInflater = getMenuInflater();
53+ menuInflater.inflate(R.menu.quit_menu, menu);
54+
55+ return true;
56+ }
57+
58+ @Override
59+ public boolean onOptionsItemSelected(MenuItem item)
60+ {
61+ boolean result;
62+ int itemId = item.getItemId();
63+ switch (itemId)
64+ {
65+ case R.id.quit_menuitem:
66+ finish();
67+ result = true;
68+ break;
69+ default:
70+ result = super.onOptionsItemSelected(item);
71+ }
72+ return result;
73+ }
74+}
--- /dev/null
+++ b/actionmode-listview-in-fragment/src/com/example/hello/android/actionmode_listview_in_fragment/UserListFragment.java
@@ -0,0 +1,174 @@
1+/*
2+ * The MIT License
3+ *
4+ * Copyright 2012-2013 Masahiko, SAWAI <masahiko.sawai@gmail.com>.
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+ * THE SOFTWARE.
23+ */
24+package com.example.hello.android.actionmode_listview_in_fragment;
25+
26+import android.app.ListFragment;
27+import android.content.res.Resources;
28+import android.os.Bundle;
29+import android.util.Log;
30+import android.view.ActionMode;
31+import android.view.LayoutInflater;
32+import android.view.Menu;
33+import android.view.MenuInflater;
34+import android.view.MenuItem;
35+import android.view.View;
36+import android.view.ViewGroup;
37+import android.widget.AbsListView.MultiChoiceModeListener;
38+import android.widget.ArrayAdapter;
39+import android.widget.ListView;
40+import java.util.ArrayList;
41+import java.util.Arrays;
42+import java.util.List;
43+
44+public class UserListFragment extends ListFragment
45+{
46+
47+ private static final String LOG_TAG = "XXX";
48+ private List<String> userListData = new ArrayList<String>();
49+ private ArrayAdapter userListAdapter;
50+
51+ @Override
52+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
53+ {
54+ View view = inflater.inflate(R.layout.user_list_fragment, null);
55+
56+ return view;
57+ }
58+
59+ @Override
60+ public void onActivityCreated(Bundle savedInstanceState)
61+ {
62+ super.onActivityCreated(savedInstanceState);
63+
64+ Resources resources = getResources();
65+ String[] names = resources.getStringArray(R.array.names);
66+ userListData.addAll(Arrays.asList(names));
67+
68+ userListAdapter = new ArrayAdapter(getActivity(),
69+ android.R.layout.simple_list_item_multiple_choice,
70+ android.R.id.text1, userListData);
71+ setListAdapter(userListAdapter);
72+
73+ ListView listView = getListView();
74+ listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
75+ listView.setMultiChoiceModeListener(new MultiChoiceDeleteModeListener());
76+ }
77+
78+ private void deleteCheckedItems()
79+ {
80+ Log.v(LOG_TAG, "deleteCheckedItems() : Hello");
81+
82+ ListView listView = getListView();
83+ long[] checkItemIds = listView.getCheckItemIds();
84+ Log.v(LOG_TAG, "deleteCheckedItems() : checkItemIds => " + checkItemIds);
85+ if (checkItemIds != null && checkItemIds.length > 0)
86+ {
87+ Log.v(LOG_TAG, "deleteCheckedItems() : checkItemIds.length => " + checkItemIds.length);
88+ for (int i = checkItemIds.length - 1; i >= 0; i--)
89+ {
90+ Log.v(LOG_TAG, "deleteCheckedItems() : delete at => " + checkItemIds[i]);
91+ userListData.remove((int) checkItemIds[i]);
92+ }
93+ userListAdapter.notifyDataSetChanged();
94+ }
95+
96+
97+ Log.v(LOG_TAG, "deleteCheckedItems() : Bye");
98+ }
99+
100+ private class MultiChoiceDeleteModeListener implements MultiChoiceModeListener
101+ {
102+
103+ public MultiChoiceDeleteModeListener()
104+ {
105+ }
106+
107+ /**
108+ * 各項目の選択状態が変わった際に呼ばれるコールバック。
109+ *
110+ * @param mode
111+ * @param position
112+ * @param id
113+ * @param checked
114+ */
115+ public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked)
116+ {
117+ Log.v(LOG_TAG, "onItemCheckedStateChanged() : Hello");
118+ Log.v(LOG_TAG, "onItemCheckedStateChanged() : position => " + position);
119+ Log.v(LOG_TAG, "onItemCheckedStateChanged() : id => " + id);
120+ Log.v(LOG_TAG, "onItemCheckedStateChanged() : checked => " + checked);
121+ Log.v(LOG_TAG, "onItemCheckedStateChanged() : Bye");
122+ }
123+
124+ public boolean onCreateActionMode(ActionMode mode, Menu menu)
125+ {
126+ Log.v(LOG_TAG, "onCreateActionMode() : Hello");
127+
128+ MenuInflater menuInflater = getActivity().getMenuInflater();
129+ menuInflater.inflate(R.menu.delete_menu, menu);
130+
131+ mode.setTitle(R.string.delete_users);
132+ mode.setSubtitle(R.string.delete_users);
133+
134+ Log.v(LOG_TAG, "onCreateActionMode() : Bye");
135+ return true;
136+ }
137+
138+ public boolean onPrepareActionMode(ActionMode mode, Menu menu)
139+ {
140+ Log.v(LOG_TAG, "onPrepareActionMode() : Hello");
141+ Log.v(LOG_TAG, "onPrepareActionMode() : Bye");
142+ return false;
143+ }
144+
145+ public boolean onActionItemClicked(ActionMode mode, MenuItem item)
146+ {
147+ Log.v(LOG_TAG, "onActionItemClicked() : Hello");
148+ int itemId = item.getItemId();
149+ switch (itemId)
150+ {
151+ case R.id.delete_menuitem:
152+ Log.v(LOG_TAG, "onActionItemClicked() : delete_menuitem is clicked.");
153+ deleteCheckedItems();
154+ mode.finish();
155+ break;
156+ }
157+ Log.v(LOG_TAG, "onActionItemClicked() : Bye");
158+ return true;
159+ }
160+
161+ /**
162+ * アクションモード終了時のコールバック。
163+ *
164+ * ActionMode#finish() を呼び出したり、左上の「×」をクリックして アクションモードが終了したときに呼ばれる。
165+ *
166+ * @param mode
167+ */
168+ public void onDestroyActionMode(ActionMode mode)
169+ {
170+ Log.v(LOG_TAG, "onDestroyActionMode() : Hello");
171+ Log.v(LOG_TAG, "onDestroyActionMode() : Bye");
172+ }
173+ }
174+}
--- a/pom.xml
+++ b/pom.xml
@@ -34,6 +34,7 @@
3434 <module>actionmode-hello</module>
3535 <module>actionmode-listview</module>
3636 <module>actionmode-listview-dynamic-layout</module>
37+ <module>actionmode-listview-fragment</module>
3738 <module>android-app-hello</module>
3839 <module>app-uuid-hello</module>
3940 <module>appwidget-gridview</module>