質問編集履歴

1

訂正版追加

2017/02/02 10:46

投稿

rvsezuki
rvsezuki

スコア66

test CHANGED
File without changes
test CHANGED
@@ -127,3 +127,125 @@
127
127
 
128
128
 
129
129
  現在上記のコードで動かしたところ(イ)から(ア)には移るのですが、(エ)部分で止まってしまいます。(エ)さえ通せれば、その後(オ)で処理をできるのですが.....
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+ 訂正版
148
+
149
+
150
+
151
+
152
+
153
+ 現在横スワイプをする方法を考えています。
154
+
155
+
156
+
157
+ ```ここに言語を入力
158
+
159
+
160
+
161
+ // タッチイベントのリスナー
162
+
163
+ private final GestureDetector.SimpleOnGestureListener mOnGestureListener = new GestureDetector.SimpleOnGestureListener() {
164
+
165
+
166
+
167
+ // フリックイベント
168
+
169
+ //@Override
170
+
171
+ public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {
172
+
173
+
174
+
175
+ try {
176
+
177
+
178
+
179
+ // 移動距離・スピードを出力
180
+
181
+ float distance_x = Math.abs((event1.getX() - event2.getX()));
182
+
183
+ float velocity_x = Math.abs(velocityX);
184
+
185
+ //textView1.setText("横の移動距離:" + distance_x + " 横の移動スピード:" + velocity_x);
186
+
187
+
188
+
189
+ // Y軸の移動距離が大きすぎる場合
190
+
191
+ if (Math.abs(event1.getY() - event2.getY()) > SWIPE_MAX_OFF_PATH) {
192
+
193
+ //textView2.setText("縦の移動距離が大きすぎ");
194
+
195
+ }
196
+
197
+ // 開始位置から終了位置の移動距離が指定値より大きい
198
+
199
+ // X軸の移動速度が指定値より大きい
200
+
201
+ //右から左へスワイプ
202
+
203
+ else if (event1.getX() - event2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
204
+
205
+ //textView2.setText("右から左");
206
+
207
+ }
208
+
209
+ // 終了位置から開始位置の移動距離が指定値より大きい
210
+
211
+ // X軸の移動速度が指定値より大きい
212
+
213
+ //左から右へスワイプ
214
+
215
+ else if (event2.getX() - event1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
216
+
217
+ //textView2.setText("左から右");
218
+
219
+ }
220
+
221
+
222
+
223
+ } catch (Exception e) {
224
+
225
+ // TODO
226
+
227
+ }
228
+
229
+ return false;
230
+
231
+ }
232
+
233
+ };
234
+
235
+
236
+
237
+ @Override
238
+
239
+ public boolean dispatchTouchEvent(final MotionEvent event) {
240
+
241
+ return super.dispatchTouchEvent(event);
242
+
243
+ }
244
+
245
+ ```
246
+
247
+
248
+
249
+ メイン画面に触れると
250
+
251
+ dispatchTouchEventメソッドに入るのですが、その後の動作がわかりません。