ios类似微信的滑动返回上一个页面是怎么实现的
1个回答
展开全部
android下滑动返回上一个页面实现的代码如下:
[java] view plaincopy
package org.sunday.slidingreturn;
import com.example.slidingreturn.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.LinearLayout;
public class SecondActivity extends Activity implements OnTouchListener {
//手指向下滑动时的最小速度
private static final int XSPEED_MIN = 200;
//手指向下滑动时的最小距离
private static final int XDISTANCE_MIN = 150;
//记录手指按下时的横坐标。
private float xDown;
//记录手指移动时的横坐标。
private float xMove;
//用于计算手指滑动的速度。
private VelocityTracker mVelocityTracker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
Button btn = (Button) findViewById(R.id.btn_second);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(SecondActivity.this, ThirdActivity.class));
overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
}
});
LinearLayout ll = (LinearLayout) findViewById(R.id.ll_second);
ll.setOnTouchListener(this);
}
[java] view plaincopy
package org.sunday.slidingreturn;
import com.example.slidingreturn.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.LinearLayout;
public class SecondActivity extends Activity implements OnTouchListener {
//手指向下滑动时的最小速度
private static final int XSPEED_MIN = 200;
//手指向下滑动时的最小距离
private static final int XDISTANCE_MIN = 150;
//记录手指按下时的横坐标。
private float xDown;
//记录手指移动时的横坐标。
private float xMove;
//用于计算手指滑动的速度。
private VelocityTracker mVelocityTracker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
Button btn = (Button) findViewById(R.id.btn_second);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(SecondActivity.this, ThirdActivity.class));
overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
}
});
LinearLayout ll = (LinearLayout) findViewById(R.id.ll_second);
ll.setOnTouchListener(this);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询