English 中文(简体)
在某些情况下,我如何将“感化”与某些儿童分开?
原标题:How do I disable the paging of a ViewPager in certain circumstances to certain childs?

我可以把观点与感化联系起来,以便采用一套老化的方法,但现在我只想暂时让一个儿童脱离。

我怀疑,我必须超越PageScrolled和取消滚动,采用一套ScrollState方法,但我可以说明如何。

问题回答

thats my solution for it:

public class NonSwipeableViewPager extends ViewPager {
    private boolean swipe = true;

    public boolean isSwipe() {
        return swipe;
    }

    public void setSwipe(boolean swipe) {
        this.swipe = swipe;
    }

    public NonSwipeableViewPager(Context context) {
        super(context);
    }

    public NonSwipeableViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent arg0) {

        if (swipe) {
            return super.onInterceptTouchEvent(arg0);
        }

        // Never allow swiping to switch between pages
        return false;
    }

}

这是我为解脱first page of a ViewPager所做的工作。 我没有使用国家变量,而是使用<代码>。 ViewPager.getAdapter(),如果我允许pe子的话,就进行检查:

public class CardViewPager extends ViewPager {

    public CardViewPager(Context context) {
        super(context);
    }

    public CardViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void setCurrentItem(int item) {
        if ((((CardFragmentAdapter) this.getAdapter()).isFirstItemDisabled())
                && (item == 0)) {
            Log.d("ViewPager", "You don t wanna see this.");
            return;
        }
        super.setCurrentItem(item);
    }
}

Of course this is only logical if you don t want to remove the page for some reason.

如果你想对第二个项目表示异议,则你可以<条码>代号>。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签