2011-09-22 41 views

回答

0

是的,改變你的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. 
0

我有同樣的問題副本的這一部分,只是增加了一個布爾變量和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); 

... 

我希望這對你的作品=)