use of android.support.v4.view.ViewPager in project ViewPagerIndicator by LuckyJayce.
the class FirstLayerFragment method onCreateViewLazy.
@Override
protected void onCreateViewLazy(Bundle savedInstanceState) {
super.onCreateViewLazy(savedInstanceState);
setContentView(R.layout.fragment_tabmain);
Resources res = getResources();
Bundle bundle = getArguments();
tabName = bundle.getString(INTENT_STRING_TABNAME);
index = bundle.getInt(INTENT_INT_INDEX);
ViewPager viewPager = (ViewPager) findViewById(R.id.fragment_tabmain_viewPager);
Indicator indicator = (Indicator) findViewById(R.id.fragment_tabmain_indicator);
switch(index) {
case 0:
indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 5));
break;
case 1:
indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 0, Gravity.CENTENT_BACKGROUND));
break;
case 2:
indicator.setScrollBar(new ColorBar(getApplicationContext(), Color.RED, 5, Gravity.TOP));
break;
case 3:
indicator.setScrollBar(new LayoutBar(getApplicationContext(), R.layout.layout_slidebar, Gravity.CENTENT_BACKGROUND));
break;
}
float unSelectSize = 16;
float selectSize = unSelectSize * 1.2f;
int selectColor = res.getColor(R.color.tab_top_text_2);
int unSelectColor = res.getColor(R.color.tab_top_text_1);
indicator.setOnTransitionListener(new OnTransitionTextListener().setColor(selectColor, unSelectColor).setSize(selectSize, unSelectSize));
viewPager.setOffscreenPageLimit(4);
indicatorViewPager = new IndicatorViewPager(indicator, viewPager);
inflate = LayoutInflater.from(getApplicationContext());
// 注意这里 的FragmentManager 是 getChildFragmentManager(); 因为是在Fragment里面
// 而在activity里面用FragmentManager 是 getSupportFragmentManager()
indicatorViewPager.setAdapter(new MyAdapter(getChildFragmentManager()));
Log.d("cccc", "Fragment 将要创建View " + this);
}
use of android.support.v4.view.ViewPager in project CircleDemo by Naoki2015.
the class ImagePagerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_imagepager);
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
guideGroup = (LinearLayout) findViewById(R.id.guideGroup);
getIntentData();
ImageAdapter mAdapter = new ImageAdapter(this);
mAdapter.setDatas(imgUrls);
mAdapter.setImageSize(imageSize);
viewPager.setAdapter(mAdapter);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
for (int i = 0; i < guideViewList.size(); i++) {
guideViewList.get(i).setSelected(i == position ? true : false);
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
viewPager.setCurrentItem(startPos);
addGuideView(guideGroup, startPos, imgUrls);
}
use of android.support.v4.view.ViewPager in project Carbon by ZieIony.
the class PagerTabStrip method initTabs.
private void initTabs() {
content.removeAllViews();
if (viewPager == null)
return;
final PagerAdapter adapter = viewPager.getAdapter();
if (viewPager.getAdapter() == null)
return;
if (tabBuilder == null) {
tabBuilder = position -> {
View tab = inflate(getContext(), R.layout.carbon_tab, null);
((TextView) tab.findViewById(R.id.carbon_tabText)).setText(getViewPager().getAdapter().getPageTitle(position).toString().toUpperCase());
return tab;
};
}
for (int i = 0; i < adapter.getCount(); i++) {
View tab = tabBuilder.getView(i);
content.addView(tab, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1f));
tab.setSelected(i == 0);
final int finalI = i;
tab.setOnClickListener(__ -> viewPager.setCurrentItem(finalI));
}
}
use of android.support.v4.view.ViewPager in project remusic by aa112901.
the class PlayingActivity method setViewPager.
private void setViewPager() {
mViewPager.setOffscreenPageLimit(2);
PlaybarPagerTransformer transformer = new PlaybarPagerTransformer();
mAdapter = new FragmentAdapter(getSupportFragmentManager());
mViewPager.setAdapter(mAdapter);
mViewPager.setPageTransformer(true, transformer);
// 改变viewpager动画时间
try {
Field mField = ViewPager.class.getDeclaredField("mScroller");
mField.setAccessible(true);
MyScroller mScroller = new MyScroller(mViewPager.getContext().getApplicationContext(), new LinearInterpolator());
mField.set(mViewPager, mScroller);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(final int pPosition) {
if (pPosition < 1) {
//首位之前,跳转到末尾(N)
MusicPlayer.setQueuePosition(MusicPlayer.getQueue().length);
mViewPager.setCurrentItem(MusicPlayer.getQueue().length, false);
isNextOrPreSetPage = false;
return;
} else if (pPosition > MusicPlayer.getQueue().length) {
//末位之后,跳转到首位(1)
MusicPlayer.setQueuePosition(0);
//false:不显示跳转过程的动画
mViewPager.setCurrentItem(1, false);
isNextOrPreSetPage = false;
return;
} else {
if (!isNextOrPreSetPage) {
if (pPosition < MusicPlayer.getQueuePosition() + 1) {
// HandlerUtil.getInstance(PlayingActivity.this).postDelayed(new Runnable() {
// @Override
// public void run() {
// // MusicPlayer.previous(PlayingActivity.this, true);
// Message msg = new Message();
// msg.what = 0;
// mPlayHandler.sendMessage(msg);
// }
// }, 500);
Message msg = new Message();
msg.what = PRE_MUSIC;
mPlayHandler.sendMessageDelayed(msg, TIME_DELAY);
} else if (pPosition > MusicPlayer.getQueuePosition() + 1) {
// HandlerUtil.getInstance(PlayingActivity.this).postDelayed(new Runnable() {
// @Override
// public void run() {
// // MusicPlayer.mNext();
//
//
// }
// }, 500);
Message msg = new Message();
msg.what = NEXT_MUSIC;
mPlayHandler.sendMessageDelayed(msg, TIME_DELAY);
}
}
}
//MusicPlayer.setQueuePosition(pPosition - 1);
isNextOrPreSetPage = false;
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageScrollStateChanged(int pState) {
}
});
}
use of android.support.v4.view.ViewPager in project remusic by aa112901.
the class TabPagerFragment method setupViewPager.
private void setupViewPager(ViewPager viewPager) {
Adapter adapter = new Adapter(getChildFragmentManager());
adapter.addFragment(new MusicFragment(), title[0]);
adapter.addFragment(new ArtistFragment(), title[1]);
adapter.addFragment(new AlbumFragment(), title[2]);
adapter.addFragment(new FolderFragment(), title[3]);
viewPager.setAdapter(adapter);
}
Aggregations