本文介绍了实施JazzyViewPager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的其他问题分支从。我试图在与本网站其他一些职位沿线设置说明,但无法得到它的工作,只是做了ViewPager行动。

Branching from my other question from HERE, I want to try and implement JazzyViewPager. I tried following the setup instructions along with a few other posts on this site, but was unable to get it working, just did the ViewPager action.

下面是相关不变(与AIDE同步问题被删除previous)code我的工作。

Below is the relevant untouched (sync issue with AIDE erased previous) code I'm working with.

MainActivity:

MainActivity:

pageAdapter = new MyPagerAdapter(getSupportFragmentManager());
final ViewPager pager = (ViewPager) findViewById(R.id.myViewPager);
pager.setAdapter(pageAdapter);
pager.setOffscreenPageLimit(1);
pager.setPageMarginDrawable(R.color.pager_bg);

MyPagerAdapter:

MyPagerAdapter:

package com.chris.myapp;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.chris.myapp.fragment.Shoutbox;
import com.chris.myapp.fragment.WebViewFragment;

import java.util.ArrayList;
import java.util.List;

public class MyPagerAdapter extends FragmentPagerAdapter {
    public static final int WEBVIEW_FRAGMENT_POSITION = 0;
    public static final int SHOUTBOX_FRAGMENT_POSITION = 1;

    private List<Fragment> fragments;

    public MyPagerAdapter(FragmentManager fm) {
        super(fm);

        this.fragments = new ArrayList<Fragment>();
        fragments.add(new WebViewFragment());
        fragments.add(new Shoutbox());
    }

    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    public int getCount() {
        return fragments.size();
    }
}

content.xml中

Content.xml

<android.support.v4.view.ViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/myViewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#111" />

任何帮助将大大AP preciated。

Any help would be greatly appreciated.

推荐答案

您可以得到包库这里

您内容的XML应该是:

You content xml should be:

<packagename.JazzyViewPager
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/myViewPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#111" />

您拨打MainAdapter类初始化的对象,您的各种屏幕:

You call the MainAdapter class to initialize the object and your various screens by:

JazzyViewPager mPager = (JazzyViewPager)findViewById(R.id.pager);
mPager.setAdapter(new MainAdapter());

各种过渡效果可供选择,如:

Various transition effects are available like:

public enum TransitionEffect {
    Standard,
    Tablet,
    CubeIn,
    CubeOut,
    Flip,
    Stack,
    ZoomIn,
    ZoomOut,
    RotateUp,
    RotateDown,
    Accordion
}

所有这些动画被放置在JazzyViewPager类,你可以调用上述任何一项提到动画:

All these animations are placed in the JazzyViewPager class and you can call any one of the above mentioned animations by:

mPager.setTransitionEffect(TransitionEffect.*);

我希望回答的帮助。我仍然无法做到这一点,然后我可以张贴code。通过这我已经实现了JazzyViewPager。

I hope the answer helps. I you still are unable to do it then i can post the code by which i have implemented the JazzyViewPager.

这篇关于实施JazzyViewPager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 08:55