質問

How to disable onScroll() programmatically in Android?

I have overriden method onScroll() in ListActivity. Now, I need to disable this method in certain part of my code. I need it for further logic.

役に立ちましたか?

解決

Without seeng any code: You could set a class level variable in your activity to false when you don't want the list to scroll. You could check this in your onScroll() handler and react accordingly.

I do have to caution you against it though. Will the user understand why it isn't scrolling, or will they be cursing your app because it has locked up?

If you were able to post some code we would be able to help more (possibly suggest a better way).

他のヒント

public class MyList extends ListView{
    private boolean isScrollEnabled = true;

    public void setScroll(boolean scrollEnabled){
        isScrollEnabled = scrollEnabled;
    }


    public void onScrollChanged(int l, int t int oldL, int oldT){
        if !(isScollingEnabled) return;
        super.onScrollChanged(l,t,oldL, oldT);
    }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top