二進制中1的個數。本站提示廣大學習愛好者:(二進制中1的個數)文章只能為提供參考,不一定能成為您想要的結果。以下是二進制中1的個數正文
public class MyGestureLintener extends SimpleOnGestureListener {
private Context context;
public MyGestureLintener(Context context) {
super();
this.context = context;
}
// 單擊,觸摸屏按下時連忙觸發
/*@Override
public boolean onDown(MotionEvent e) {
// TODO Auto-generated method stub
Toast.makeText(context, "Down " + e.getAction(), Toast.LENGTH_SHORT)
.show();
return true;
}*/
// 雙擊,手指在觸摸屏上敏捷點擊第二下時觸發
@Override
public boolean onDoubleTap(MotionEvent e) {
// TODO Auto-generated method stub
return super.onDoubleTap(e);
}
// 雙擊的按下跟抬起各觸發一次
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
// TODO Auto-generated method stub
return super.onDoubleTapEvent(e);
}
// 滑動,觸摸屏按下後疾速挪動並抬起,會先觸發轉動手勢,隨著觸發一個滑著手勢
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
// TODO Auto-generated method stub
return super.onFling(e1, e2, velocityX, velocityY);
}
// 長按,觸摸屏按下後既不抬起也不挪動,過一段時光後觸發
@Override
public void onLongPress(MotionEvent e) {
// TODO Auto-generated method stub
Toast.makeText(context, "LONG " + e.getAction(), Toast.LENGTH_SHORT)
.show();
}
// 轉動,觸摸屏按下後挪動
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
Toast.makeText(context, "onScroll " + e2.getAction(), Toast.LENGTH_SHORT)
.show();
return true;
}
// 短按,觸摸屏按下後少焉後抬起,會觸發這個手勢,假如敏捷抬起則不會
@Override
public void onShowPress(MotionEvent e) {
// TODO Auto-generated method stub
Toast.makeText(context, "Show " + e.getAction(), Toast.LENGTH_SHORT)
.show();
}
// 單擊確認,即很快的按下並抬起,但其實不持續點擊第二下
/*@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
// TODO Auto-generated method stub
Toast.makeText(context, "onSingleTapConfirmed " + e.getAction(), Toast.LENGTH_SHORT)
.show();
return true;
}*/
// 抬起,手指分開觸摸屏時觸發(長按、轉動、滑動時,不會觸發這個手勢)
/*@Override
public boolean onSingleTapUp(MotionEvent e) {
// TODO Auto-generated method stub
Toast.makeText(context, "onSingleTapUp " + e.getAction(), Toast.LENGTH_SHORT)
.show();
return true;
}*/
public class MainActivity extends Activity {
private GestureDetector mGestureDetector;//手勢對象
private MyGestureLintener myGestureLintener;//手勢監聽的接口對象
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myGestureLintener = new MyGestureLintener(this);
//手勢對象的結構辦法
mGestureDetector = new GestureDetector(this,
myGestureLintener);
}
/**GestureDetector類的onTouchEvent辦法用來鑒別分歧的手勢*/
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean b = false;
int i = event.getAction();
int j = MotionEvent.ACTION_MOVE;
System.out.println(i+"<----------------->"+j);
b = mGestureDetector.onTouchEvent(event);
if (b) {
Intent in = new Intent();
in.setClass(this, testActivity.class);
startActivity(in);
}
return b;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}