有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (2) 个答案

  1. # 1 楼答案

    是的,更改ViewFlow副本的这一部分

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
    ....
        case MotionEvent.ACTION_MOVE:
        //Add an if / else here that validates your input. 
        //If it is incorrect don't let the rest of the code that is here do the scrolling.
    
  2. # 2 楼答案

    我也有同样的问题,只是添加了一个布尔变量和一个setter和getter:

    ...
    public class ViewFlow extends AdapterView<Adapter> {
        private Boolean flagAllowScroll = false;
       //the rest of the code
        ...
    
    public Boolean getFlagAllowScroll() {
      return flagAllowScroll;
    }
    
    public void setFlagAllowScroll(Boolean flagAllowScroll) {
      this.flagAllowScroll = flagAllowScroll;
    }
    

    然后把它放在onTouchEvent函数上

    ...
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
    if (!getFlagAllowScroll())
        return false;
        //the rest of the code
    ...
    

    以及onInterceptTouchEvent函数中的其他

    ...
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
    if (!getFlagAllowScroll())
        return false;
        //the rest of the code
    ...
    

    这样改变它:

    ...
    //Allows changes
    viewFlow.setFlagAllowScroll(true);
    
    ...
    
    //Doesn't Allows changes
    viewFlow.setFlagAllowScroll(false);
    
    ...
    

    我希望这对你有用()