-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathHoverEmulatorActivity.java
More file actions
45 lines (38 loc) · 1.23 KB
/
Copy pathHoverEmulatorActivity.java
File metadata and controls
45 lines (38 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package com.examples.customtouch;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
/**
* Created by Dave Smith
* Xcellent Creations, Inc.
* Date: 12/5/12
* HoverEmulatorActivity
* Transform touch events into hover events
*/
public class HoverEmulatorActivity extends Activity implements View.OnHoverListener {
public static final String TAG = "HoverEmulatorActivity";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hover_emulator);
findViewById(R.id.button_hover).setOnHoverListener(this);
}
@Override
public boolean onHover(View v, MotionEvent event) {
Log.i(TAG, "Hover Event "+getHoverName(event));
return false;
}
private String getHoverName(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_HOVER_ENTER:
return "HOVER_ENTER";
case MotionEvent.ACTION_HOVER_MOVE:
return "HOVER_MOVE";
case MotionEvent.ACTION_HOVER_EXIT:
return "HOVER_EXIT";
default:
return "";
}
}
}