在这种情况下会出现“应以静态方式访问if((detail.VISIBLE) && (pod.GONE) && (photo.GONE))
静态字段”的错误View.GONE
...
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float velocityX, float velocityY) {
final RelativeLayout detail = (RelativeLayout) findViewById(R.id.layout_detail);
final RelativeLayout photo = (RelativeLayout) findViewById(R.id.layout_detail_photo);
final RelativeLayout pod = (RelativeLayout) findViewById(R.id.layout_detail_pod);
final ToggleButton btn_detail = (ToggleButton) findViewById(R.id.btn_detail);
final ToggleButton btn_pod = (ToggleButton) findViewById(R.id.btn_pod);
final ToggleButton btn_photo = (ToggleButton) findViewById(R.id.btn_photo);
// right to left swipe
if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE &&
Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
Toast.makeText(this, "Left Swipe", Toast.LENGTH_SHORT).show();
if((detail.VISIBLE) && (pod.GONE) && (photo.GONE)) {
detail.setVisibility(View.GONE);
photo.setVisibility(View.GONE);
pod.setVisibility(View.VISIBLE);
btn_photo.setSelected(false);
btn_pod.setSelected(true);
btn_detail.setSelected(false);
}
}
// left to right swipe
else if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE &&
Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
Toast.makeText(this, "Right Swipe", Toast.LENGTH_SHORT).show();
}
return true;
}