That's not the answer to the question.android.R.anim.slide_out_right is defined elsewhere and is accessible from R.anim.
Slide_in_right is not accessible from this package, hence the need to use the xml file definition
I managed to access the animation by copying the files in frameworks/base/core/res/res/anim/slide_in_right.xml to res/anim/slide_in_right.xml and used the code:
AnimationUtils.loadAnimation(this, R.anim.slide_in_right);
to load the animation.
The full code to achieve an onTouchListener that allows the user to slide an image left to veiw next and slide an image right to view previous is shown below
/**
* @return
*/
protected OnTouchListener createOnTouch() {
return new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if ((event.getAction() == MotionEvent.ACTION_DOWN) || (event.getAction() == MotionEvent.ACTION_POINTER_DOWN)) {
downX = (int) event.getX();
Log.i("event.getX()", " downX " + downX);
return true;
} else if ((event.getAction() == MotionEvent.ACTION_UP) || (event.getAction() == MotionEvent.ACTION_POINTER_UP)) {
upX = (int) event.getX();
Log.i("event.getX()", " upX " + upX);
Log.d("event.getX()", " upX-downX " + (upX - downX));
Log.d("event.getX()", " downX-upX " + (downX - upX));
if (upX - downX > 100) {
imageSwitcher1.setInAnimation(AnimationUtils.loadAnimation(ImageDisplayActivity.this, android.R.anim.slide_in_left));
imageSwitcher1.setOutAnimation(AnimationUtils.loadAnimation(ImageDisplayActivity.this, android.R.anim.slide_out_right));
int newPosition = selected - 1;
showDetails(newPosition, gallery.getChildAt(newPosition));
// ImageDisplayActivity.this.switchTitle(curIndex);
} else if (downX - upX > 100) {
imageSwitcher1.setInAnimation(AnimationUtils.loadAnimation(ImageDisplayActivity.this, R.anim.slide_in_right));
imageSwitcher1.setOutAnimation(AnimationUtils.loadAnimation(ImageDisplayActivity.this, R.anim.slide_out_left));
int newPosition = selected + 1;
showDetails(newPosition, gallery.getChildAt(newPosition));
} else {
return false;
}
return true;
}
return false;
}
};
}