我正在开发一个锁屏,我想在两个活动之间滑动,比如我们刷主屏幕。我到处搜索,但我找不到任何完美的答案。我使用了view pager但它没有处理活动。 然后我尝试了这个:
public void change(){
int1= new Intent(this,WheelActivity.class);
startActivityForResult(int1,1000);
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
finish();
}
public void change1(){
int1= new Intent(this,ImageActivity.class);
startActivityForResult(int1,1000);
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
finish();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
@Override
public boolean onTouchEvent(MotionEvent me) {
return gDetector.onTouchEvent(me);
}
@Override
public boolean onDown(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean onFling(MotionEvent start, MotionEvent finish, float xVelocity, float yVelocity) {
if (start.getRawX() < finish.getRawX()) {
change();
}
if (start.getRawX() > finish.getRawX()) {
change1();
}
return true;
}
@Override
public void onLongPress(MotionEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2,
float arg3) {
// TODO Auto-generated method stub
return false;
}
@Override
public void onShowPress(MotionEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public boolean onSingleTapUp(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}
但问题是它不像主屏幕滑动或任何其他锁屏那么平滑。请帮我解决这个问题。 提前谢谢。