鸿 网 互 联 www.68idc.cn

当前位置 : 服务器租用 > 手机系统开发 > android > >

GestureFlip

来源:互联网 作者:佚名 时间:2012-12-12 10:54
翻页 public class MainActivity extends Activity implements OnGestureListener { private GestureDetector gd; FLIP_DISTANCE = 50 ; private TextView tv1, tv2;@Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedI

翻页

public class MainActivity extends Activity implements OnGestureListener { private GestureDetector gd; FLIP_DISTANCE = 50; private TextView tv1, tv2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); createView(); gd = new GestureDetector(this); } protected void createView() { // TODO Auto-generated method stub tv1 = (TextView) findViewById(R.id.tv1); tv2 = (TextView) findViewById(R.id.tv2); } @Override public boolean onDown(MotionEvent arg0) { ; } @Override public boolean onFling(MotionEvent arg0, MotionEvent arg1, float arg2, float arg3) { (Math.abs(arg0.getX() - arg1.getX()) > FLIP_DISTANCE) { if (tv1.getVisibility() == View.VISIBLE) { tv1.setVisibility(View.INVISIBLE); tv2.setVisibility(View.VISIBLE); } else { tv1.setVisibility(View.VISIBLE); tv2.setVisibility(View.INVISIBLE); } } return false; } @Override public void onLongPress(MotionEvent arg0) { // TODO Auto-generated method stub } @Override public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2, float arg3) { ; } @Override public void onShowPress(MotionEvent arg0) { // TODO Auto-generated method stub } @Override public boolean onSingleTapUp(MotionEvent arg0) { ; } @Override public boolean onTouchEvent(MotionEvent event) { gd.onTouchEvent(event); } }香港服务器香港服务器服务器空间

网友评论
<