Android Samples
リビジョン | ca78db6cdaf6f097acea95645c7106b66771d69b (tree) |
---|---|
日時 | 2013-10-28 16:31:48 |
作者 | Masahiko, SAWAI <say@user...> |
コミッター | Masahiko, SAWAI |
Added scrollview-on-scroll-changed project
@@ -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.scrollview_on_scroll_changed" | |
4 | + android:versionCode="1" | |
5 | + android:versionName="1.0" | |
6 | +> | |
7 | + <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="11" /> | |
8 | + | |
9 | + <application android:label="@string/app_name"> | |
10 | + <activity android:name=".MainActivity" | |
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> |
@@ -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 $@ |
@@ -0,0 +1,29 @@ | ||
1 | +! scrollview-on-scroll-changed | |
2 | + | |
3 | +ScrollView を継承して onScrollChanged() をオーバーライドしたクラス | |
4 | +を作成してスクロール位置変更時に処理を実行するサンプル。 | |
5 | + | |
6 | +* View#onScrollChanged(int l, int t, int oldl, int oldt) : void | |
7 | + * l 水平方向のスクロール位置 | |
8 | + * t 垂直方向のスクロール位置 | |
9 | + * oldl 直前の水平方向のスクロール位置 | |
10 | + * oldt 直前の垂直方向のスクロール位置 | |
11 | + | |
12 | + | |
13 | +############################################################ | |
14 | +!! ビルドターゲット | |
15 | + | |
16 | +http://maven-android-plugin-m2site.googlecode.com/svn/plugin-info.html | |
17 | + | |
18 | +* mvn compile - アプリケーションのコンパイル | |
19 | +* mvn package - apk の作成 | |
20 | +* mvn clean - ビルドファイルの削除 | |
21 | +* mvn install - maven の local リポジトリにインストール | |
22 | + | |
23 | +* mvn android:deploy - エミュレータやデバイスにインストール | |
24 | +* mvn android:generate-sources | |
25 | + | |
26 | +* mvn install - アプリケーションのインストール | |
27 | +* mvn uninstall - アプリケーションのアンインストール | |
28 | + | |
29 | + |
@@ -0,0 +1,148 @@ | ||
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>scrollview-on-scroll-changed</artifactId> | |
10 | + <packaging>apk</packaging> | |
11 | + <version>1.0.0</version> | |
12 | + <name>ScrollView : onScrollChanged()</name> | |
13 | + <url>http://www.example.com/</url> | |
14 | + | |
15 | + <parent> | |
16 | + <groupId>com.example.hello</groupId> | |
17 | + <artifactId>android-samples</artifactId> | |
18 | + <version>1.0.0</version> | |
19 | + </parent> | |
20 | + | |
21 | + <dependencies> | |
22 | + | |
23 | + <dependency> | |
24 | + <groupId>android</groupId> | |
25 | + <artifactId>android</artifactId> | |
26 | + <version>1.5_r4</version> | |
27 | + <!-- | |
28 | + <version>1.5_r3</version> | |
29 | + <version>1.5_r4</version> | |
30 | + <version>1.6_r2</version> | |
31 | + <version>2.1.2</version> | |
32 | + <version>2.1_r1</version> | |
33 | + <version>2.2.1</version> | |
34 | + <version>2.3.1</version> | |
35 | + <version>2.3.3</version> | |
36 | + <version>4.0.1.2</version> | |
37 | + --> | |
38 | + <scope>provided</scope> | |
39 | + </dependency> | |
40 | + | |
41 | + <dependency> | |
42 | + <groupId>junit</groupId> | |
43 | + <artifactId>junit</artifactId> | |
44 | + <scope>test</scope> | |
45 | + </dependency> | |
46 | + </dependencies> | |
47 | + | |
48 | + <build> | |
49 | + <sourceDirectory>src</sourceDirectory> | |
50 | + | |
51 | + <plugins> | |
52 | + <plugin> | |
53 | + <groupId>com.jayway.maven.plugins.android.generation2</groupId> | |
54 | + <artifactId>android-maven-plugin</artifactId> | |
55 | + <configuration> | |
56 | + <sdk> | |
57 | + <path>${env.ANDROID_HOME}</path> | |
58 | + <!-- <path>C:/Java/android-sdk</path> --> | |
59 | + <platform>8</platform> | |
60 | + </sdk> | |
61 | + <proguard> | |
62 | + <skip>true</skip> | |
63 | + <config>proguard.conf</config> | |
64 | + </proguard> | |
65 | + <extractDuplicates>true</extractDuplicates> | |
66 | + </configuration> | |
67 | + <extensions>true</extensions> | |
68 | + </plugin> | |
69 | + | |
70 | + <!-- mvn compile --> | |
71 | + <plugin> | |
72 | + <groupId>org.apache.maven.plugins</groupId> | |
73 | + <artifactId>maven-compiler-plugin</artifactId> | |
74 | + <configuration> | |
75 | + <source>1.5</source> | |
76 | + <target>1.5</target> | |
77 | + <encoding>UTF-8</encoding> | |
78 | + </configuration> | |
79 | + </plugin> | |
80 | + | |
81 | + <!-- mvn assembly:assembly --> | |
82 | + <plugin> | |
83 | + <groupId>org.apache.maven.plugins</groupId> | |
84 | + <artifactId>maven-assembly-plugin</artifactId> | |
85 | + <configuration> | |
86 | + <descriptorRefs> | |
87 | + <!-- | |
88 | + <descriptorRef>jar-with-dependencies</descriptorRef> | |
89 | + <descriptorRef>bin</descriptorRef> | |
90 | + <descriptorRef>src</descriptorRef> | |
91 | + --> | |
92 | + <descriptorRef>project</descriptorRef> | |
93 | + </descriptorRefs> | |
94 | + </configuration> | |
95 | + </plugin> | |
96 | + | |
97 | + <!-- mvn resources:resources --> | |
98 | + <plugin> | |
99 | + <groupId>org.apache.maven.plugins</groupId> | |
100 | + <artifactId>maven-resources-plugin</artifactId> | |
101 | + <configuration> | |
102 | + <encoding>UTF-8</encoding> | |
103 | + </configuration> | |
104 | + </plugin> | |
105 | + | |
106 | + <!-- mvn site --> | |
107 | + <plugin> | |
108 | + <groupId>org.apache.maven.plugins</groupId> | |
109 | + <artifactId>maven-site-plugin</artifactId> | |
110 | + <configuration> | |
111 | + <locales>en</locales> | |
112 | + <inputEncoding>UTF-8</inputEncoding> | |
113 | + <outputEncoding>UTF-8</outputEncoding> | |
114 | + | |
115 | + <reportPlugins> | |
116 | + <plugin> | |
117 | + <groupId>org.apache.maven.plugins</groupId> | |
118 | + <artifactId>maven-project-info-reports-plugin</artifactId> | |
119 | + </plugin> | |
120 | + | |
121 | + <!-- mvn javadoc:javadoc --> | |
122 | + <plugin> | |
123 | + <groupId>org.apache.maven.plugins</groupId> | |
124 | + <artifactId>maven-javadoc-plugin</artifactId> | |
125 | + <configuration> | |
126 | + <charset>utf-8</charset> | |
127 | + </configuration> | |
128 | + </plugin> | |
129 | + </reportPlugins> | |
130 | + </configuration> | |
131 | + </plugin> | |
132 | + | |
133 | + </plugins> | |
134 | + | |
135 | + <!-- mvn resources:resources --> | |
136 | + <resources> | |
137 | + <resource> | |
138 | + <directory>res</directory> | |
139 | + <filtering>false</filtering> | |
140 | + <includes> | |
141 | + <include>**/*.properties</include> | |
142 | + </includes> | |
143 | + </resource> | |
144 | + </resources> | |
145 | + </build> | |
146 | + | |
147 | + | |
148 | +</project> |
@@ -0,0 +1,114 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<com.example.hello.android.scrollview_on_scroll_changed.MyScrollView | |
3 | + xmlns:android="http://schemas.android.com/apk/res/android" | |
4 | + android:layout_width="fill_parent" | |
5 | + android:layout_height="fill_parent" | |
6 | + android:fillViewport="true" | |
7 | +> | |
8 | + <LinearLayout | |
9 | + android:orientation="vertical" | |
10 | + android:layout_width="fill_parent" | |
11 | + android:layout_height="fill_parent" | |
12 | + > | |
13 | + <TextView style="@style/sample_textview" /> | |
14 | + <TextView style="@style/sample_textview" /> | |
15 | + <TextView style="@style/sample_textview" /> | |
16 | + <TextView style="@style/sample_textview" /> | |
17 | + <TextView style="@style/sample_textview" /> | |
18 | + <TextView style="@style/sample_textview" /> | |
19 | + <TextView style="@style/sample_textview" /> | |
20 | + <TextView style="@style/sample_textview" /> | |
21 | + <TextView style="@style/sample_textview" /> | |
22 | + <TextView style="@style/sample_textview" /> | |
23 | + <TextView style="@style/sample_textview" /> | |
24 | + <TextView style="@style/sample_textview" /> | |
25 | + <TextView style="@style/sample_textview" /> | |
26 | + <TextView style="@style/sample_textview" /> | |
27 | + <TextView style="@style/sample_textview" /> | |
28 | + <TextView style="@style/sample_textview" /> | |
29 | + <TextView style="@style/sample_textview" /> | |
30 | + <TextView style="@style/sample_textview" /> | |
31 | + <TextView style="@style/sample_textview" /> | |
32 | + <TextView style="@style/sample_textview" /> | |
33 | + <TextView style="@style/sample_textview" /> | |
34 | + <TextView style="@style/sample_textview" /> | |
35 | + <TextView style="@style/sample_textview" /> | |
36 | + <TextView style="@style/sample_textview" /> | |
37 | + <TextView style="@style/sample_textview" /> | |
38 | + <TextView style="@style/sample_textview" /> | |
39 | + <TextView style="@style/sample_textview" /> | |
40 | + <TextView style="@style/sample_textview" /> | |
41 | + <TextView style="@style/sample_textview" /> | |
42 | + <TextView style="@style/sample_textview" /> | |
43 | + <TextView style="@style/sample_textview" /> | |
44 | + <TextView style="@style/sample_textview" /> | |
45 | + <TextView style="@style/sample_textview" /> | |
46 | + <TextView style="@style/sample_textview" /> | |
47 | + <TextView style="@style/sample_textview" /> | |
48 | + <TextView style="@style/sample_textview" /> | |
49 | + <TextView style="@style/sample_textview" /> | |
50 | + <TextView style="@style/sample_textview" /> | |
51 | + <TextView style="@style/sample_textview" /> | |
52 | + <TextView style="@style/sample_textview" /> | |
53 | + <TextView style="@style/sample_textview" /> | |
54 | + <TextView style="@style/sample_textview" /> | |
55 | + <TextView style="@style/sample_textview" /> | |
56 | + <TextView style="@style/sample_textview" /> | |
57 | + <TextView style="@style/sample_textview" /> | |
58 | + <TextView style="@style/sample_textview" /> | |
59 | + <TextView style="@style/sample_textview" /> | |
60 | + <TextView style="@style/sample_textview" /> | |
61 | + <TextView style="@style/sample_textview" /> | |
62 | + <TextView style="@style/sample_textview" /> | |
63 | + <TextView style="@style/sample_textview" /> | |
64 | + <TextView style="@style/sample_textview" /> | |
65 | + <TextView style="@style/sample_textview" /> | |
66 | + <TextView style="@style/sample_textview" /> | |
67 | + <TextView style="@style/sample_textview" /> | |
68 | + <TextView style="@style/sample_textview" /> | |
69 | + <TextView style="@style/sample_textview" /> | |
70 | + <TextView style="@style/sample_textview" /> | |
71 | + <TextView style="@style/sample_textview" /> | |
72 | + <TextView style="@style/sample_textview" /> | |
73 | + <TextView style="@style/sample_textview" /> | |
74 | + <TextView style="@style/sample_textview" /> | |
75 | + <TextView style="@style/sample_textview" /> | |
76 | + <TextView style="@style/sample_textview" /> | |
77 | + <TextView style="@style/sample_textview" /> | |
78 | + <TextView style="@style/sample_textview" /> | |
79 | + <TextView style="@style/sample_textview" /> | |
80 | + <TextView style="@style/sample_textview" /> | |
81 | + <TextView style="@style/sample_textview" /> | |
82 | + <TextView style="@style/sample_textview" /> | |
83 | + <TextView style="@style/sample_textview" /> | |
84 | + <TextView style="@style/sample_textview" /> | |
85 | + <TextView style="@style/sample_textview" /> | |
86 | + <TextView style="@style/sample_textview" /> | |
87 | + <TextView style="@style/sample_textview" /> | |
88 | + <TextView style="@style/sample_textview" /> | |
89 | + <TextView style="@style/sample_textview" /> | |
90 | + <TextView style="@style/sample_textview" /> | |
91 | + <TextView style="@style/sample_textview" /> | |
92 | + <TextView style="@style/sample_textview" /> | |
93 | + <TextView style="@style/sample_textview" /> | |
94 | + <TextView style="@style/sample_textview" /> | |
95 | + <TextView style="@style/sample_textview" /> | |
96 | + <TextView style="@style/sample_textview" /> | |
97 | + <TextView style="@style/sample_textview" /> | |
98 | + <TextView style="@style/sample_textview" /> | |
99 | + <TextView style="@style/sample_textview" /> | |
100 | + <TextView style="@style/sample_textview" /> | |
101 | + <TextView style="@style/sample_textview" /> | |
102 | + <TextView style="@style/sample_textview" /> | |
103 | + <TextView style="@style/sample_textview" /> | |
104 | + <TextView style="@style/sample_textview" /> | |
105 | + <TextView style="@style/sample_textview" /> | |
106 | + <TextView style="@style/sample_textview" /> | |
107 | + <TextView style="@style/sample_textview" /> | |
108 | + <TextView style="@style/sample_textview" /> | |
109 | + <TextView style="@style/sample_textview" /> | |
110 | + <TextView style="@style/sample_textview" /> | |
111 | + <TextView style="@style/sample_textview" /> | |
112 | + <TextView style="@style/sample_textview" /> | |
113 | + </LinearLayout> | |
114 | +</com.example.hello.android.scrollview_on_scroll_changed.MyScrollView> | |
\ No newline at end of file |
@@ -0,0 +1,8 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<!-- | |
3 | +* How to define string resource | |
4 | +--> | |
5 | +<resources> | |
6 | + <string name="app_name">onScrollChanged()</string> | |
7 | + <string name="hello">Hello Android World!</string> | |
8 | +</resources> |
@@ -0,0 +1,14 @@ | ||
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<!-- | |
3 | +* How to define string resource | |
4 | +--> | |
5 | +<resources> | |
6 | + <style name="sample_textview"> | |
7 | + <item name="android:layout_width">fill_parent</item> | |
8 | + <item name="android:layout_height">wrap_content</item> | |
9 | + <item name="android:layout_weight">0</item> | |
10 | + <item name="android:layout_margin">8dip</item> | |
11 | + <item name="android:textSize">20sp</item> | |
12 | + <item name="android:text">@string/hello</item> | |
13 | + </style> | |
14 | +</resources> |
@@ -0,0 +1,38 @@ | ||
1 | +/* | |
2 | + * The MIT License | |
3 | + * | |
4 | + * Copyright 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.scrollview_on_scroll_changed; | |
25 | + | |
26 | +import android.app.Activity; | |
27 | +import android.os.Bundle; | |
28 | + | |
29 | +public class MainActivity extends Activity | |
30 | +{ | |
31 | + | |
32 | + @Override | |
33 | + public void onCreate(Bundle savedInstanceState) | |
34 | + { | |
35 | + super.onCreate(savedInstanceState); | |
36 | + setContentView(R.layout.main_activity); | |
37 | + } | |
38 | +} |
@@ -0,0 +1,65 @@ | ||
1 | +/* | |
2 | + * The MIT License | |
3 | + * | |
4 | + * Copyright 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.scrollview_on_scroll_changed; | |
25 | + | |
26 | +import android.content.Context; | |
27 | +import android.util.AttributeSet; | |
28 | +import android.util.Log; | |
29 | +import android.widget.ScrollView; | |
30 | + | |
31 | +/** | |
32 | + * | |
33 | + * @author Masahiko, SAWAI <masahiko.sawai@gmail.com> | |
34 | + */ | |
35 | +public class MyScrollView extends ScrollView | |
36 | +{ | |
37 | + | |
38 | + private static final String LOG_TAG = "XXX"; | |
39 | + | |
40 | + public MyScrollView(Context context) | |
41 | + { | |
42 | + super(context); | |
43 | + } | |
44 | + | |
45 | + public MyScrollView(Context context, AttributeSet attrs) | |
46 | + { | |
47 | + super(context, attrs); | |
48 | + } | |
49 | + | |
50 | + public MyScrollView(Context context, AttributeSet attrs, int defStyle) | |
51 | + { | |
52 | + super(context, attrs, defStyle); | |
53 | + } | |
54 | + | |
55 | + @Override | |
56 | + protected void onScrollChanged(int l, int t, int oldl, int oldt) | |
57 | + { | |
58 | + super.onScrollChanged(l, t, oldl, oldt); | |
59 | + Log.d(LOG_TAG, "onScrollChanged(l => " + l + ", t => " + t + ", oldl => " + oldl + ", oldt => " + oldt + ")"); | |
60 | + if (t <= 0 && oldt <= 0) | |
61 | + { | |
62 | + Log.d(LOG_TAG, "onScrollChanged() : I'm on top of the ScrollView!"); | |
63 | + } | |
64 | + } | |
65 | +} |