Thanks to Code Shogun, whose code I adapted to my situation.
Let your activity implementOnClickListener
as usual:
public class SelectFilterActivity extends Activity implements OnClickListener {
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
private GestureDetector gestureDetector;
View.OnTouchListener gestureListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* ... */
// Gesture detection
gestureDetector = new GestureDetector(this, new MyGestureDetector());
gestureListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
};
}
class MyGestureDetector extends SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
try {
if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
return false;
// right to left swipe
if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
Toast.makeText(SelectFilterActivity.this, "Left Swipe", Toast.LENGTH_SHORT).show();
} else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
Toast.makeText(SelectFilterActivity.this, "Right Swipe", Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
// nothing
}
return false;
}
@Override
public boolean onDown(MotionEvent e) {
return true;
}
}
}
Attach your gesture listener to all the views you add to the main layout;
// Do this for each view added to the grid
imageView.setOnClickListener(SelectFilterActivity.this);
imageView.setOnTouchListener(gestureListener);
Watch in awe as your overridden methods are hit, both the onClick(View v)
of the activity and the onFling
of the gesture listener.
public void onClick(View v) {
Filter f = (Filter) v.getTag();
FilterFullscreenActivity.show(this, input, f);
}
The post 'fling' dance is optional but encouraged.
From AVD Manager when starting the emulator, choose "Scale Display to Real Size"
Set the Screen Size (I used 7 because Galaxy Tab has a 7 inch display, you can set anything that fits in your monitor) which will fit in your monitor. This is the size of the emulator screen.
Set monitor resolution (dpi). This is in almost all cases 96dpi. This is the actual resolution of your computer monitor.
Now start, you are done :)
About minimum resolution:
Samsung Galaxy Tab resolution is: 600x1024
So, the vertical resolution of your monitor should be at least 1024 (which is currently 900). I say at least because there is the windows taskbar.
You can use Ctrl+F11 when the emulator is loaded to rotate it and get to the landscape mode. Tab's landscape resolution becomes 1024x900 (reversed)
You will notice that, in landscape mode, it fits your screen (as your 1600x900 is larger than 1024x600)
Your monitor is 16:9, so keeping the same ratio, so if you could set something like 1820x1024, the emulator would fit in portrait mode.
I think you got the point.
Best Answer
UPDATED:
Matt provided a great link on how to add emulators for all Samsung devices.
OLD:
To get the official Samsung Galaxy Tab emulator do the following:
That's it!