本文整理汇总了Java中android.support.v4.view.ViewPager.setAdapter方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPager.setAdapter方法的具体用法?Java ViewPager.setAdapter怎么用?Java ViewPager.setAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.ViewPager
的用法示例。
在下文中一共展示了ViewPager.setAdapter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
FDroidApp fdroidApp = (FDroidApp) getApplication();
fdroidApp.applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screenshots);
String packageName = getIntent().getStringExtra(EXTRA_PACKAGE_NAME);
int startPosition = getIntent().getIntExtra(EXTRA_START_POSITION, 0);
App app = AppProvider.Helper.findHighestPriorityMetadata(getContentResolver(), packageName);
String[] screenshots = app.getAllScreenshots(this);
ViewPager viewPager = (ViewPager) findViewById(R.id.screenshot_view_pager);
ScreenShotPagerAdapter adapter = new ScreenShotPagerAdapter(getSupportFragmentManager(), screenshots);
viewPager.setAdapter(adapter);
viewPager.setCurrentItem(startPosition);
if (Build.VERSION.SDK_INT >= 11) {
// display some nice animation while swiping
viewPager.setPageTransformer(true, new DepthPageTransformer());
}
}
示例2: initUI
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void initUI(){
previewOperationBar = (LinearLayout) findViewById(R.id.picker_image_preview_operator_bar);
originalImage = (ImageButton) findViewById(R.id.picker_image_preview_orignal_image);
originalImage.setOnClickListener(this);
originalImageSizeTip = (TextView) findViewById(R.id.picker_image_preview_orignal_image_tip);
if(!isSupportOriginal){
originalImage.setVisibility(View.INVISIBLE);
originalImageSizeTip.setVisibility(View.INVISIBLE);
}
previewSendBtn = (TextView) findViewById(R.id.picker_image_preview_send);
previewSendBtn.setOnClickListener(this);
updateSelectBtnStatus();
updateOriImageSizeTip(isSendOriginalImage);
imageViewPager = (ViewPager) findViewById(R.id.picker_image_preview_viewpager);
imageViewPager.setOnPageChangeListener(this);
imageViewPager.setOffscreenPageLimit(2);
imageViewPagerAdapter = new PickerPreviewPagerAdapter(this, photoLists, getLayoutInflater(),
imageViewPager.getLayoutParams().width, imageViewPager.getLayoutParams().height, this);
imageViewPager.setAdapter(imageViewPagerAdapter);
setTitleIndex(firstDisplayImageIndex);
updateTitleSelect(firstDisplayImageIndex);
imageViewPager.setCurrentItem(firstDisplayImageIndex);
}
示例3: onCreateView
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mContext = (Context) getActivity();
View v = inflater.inflate(R.layout.introduction_fragment, container, false);
// Instantiate a ViewPager and a PagerAdapter.
mPager = (ViewPager) v.findViewById(R.id.pager);
mPagerAdapter = new IntroductionPagerAdapter();
mPager.setAdapter(mPagerAdapter);
return v;
}
示例4: setupViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public void setupViewPager(ViewPager viewPager) {
//此处bug严重
ViewPagerAdapter adapter = new ViewPagerAdapter(getChildFragmentManager());
//最热单独放一个标签
for(int i = 0 ; i< mTbClass.size() ;i++){
mtabLayout.addTab(mtabLayout.newTab().setText(mTbClass.get(i).getClassname()));
Bundle data = new Bundle();
data.putInt("classid", mTbClass.get(i).getClassid());
data.putString("classname", mTbClass.get(i).getClassname());
Fragment newfragment = new ContentHomeFragment();
newfragment.setArguments(data);
adapter.addFrag(newfragment, mTbClass.get(i).getClassname());
}
viewPager.setAdapter(adapter);
mtabLayout.setupWithViewPager(viewPager);
}
示例5: onCreateView
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fr_image_pager, container, false);
ViewPager pager = (ViewPager) rootView.findViewById(R.id.pager);
pager.setAdapter(new ImageAdapter(getActivity()));
pager.setCurrentItem(getArguments().getInt(Constants.Extra.IMAGE_POSITION, 0));
return rootView;
}
示例6: bindView
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void bindView() {
mCoordinatorLayout = findViewById(R.id.container);
String text = getTextFromAnotherApp();
ViewPager viewPager = findViewById(R.id.view_pager);
FragmentPagerAdapter adapter = getPageAdapter(text);
viewPager.setOffscreenPageLimit(adapter.getCount());
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(this);
((SmartTabLayout) findViewById(R.id.tab_layout)).setViewPager(viewPager);
//attach listener hide/show keyboard
KeyBoardEventListener keyBoardEventListener = new KeyBoardEventListener(this);
mCoordinatorLayout.getViewTreeObserver().addOnGlobalLayoutListener(keyBoardEventListener);
}
示例7: onCreate
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
viewpager = (ViewPager) findViewById(R.id.pager);
PagerAdapter padapter = new PagerAdapter(getSupportFragmentManager());
viewpager.setAdapter(padapter);
}
示例8: initContentView
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public void initContentView() {
// 底部
footer = (CustomRadioGroup) findViewById(R.id.main_footer);
for (int i = 0; i <getMenus().size(); i++) {
footer.addItem(getMenus().get(i).iconNormal,
getMenus().get(i).iconPressed,
getMenus().get(i).name);
}
// 主体
body = (ViewPager) findViewById(R.id.main_body);
final MainBodyPageChangeListener bodyChangeListener = new MainBodyPageChangeListener(
footer);
body.setOnPageChangeListener(bodyChangeListener);
initFragments();
body.setOffscreenPageLimit(10);
MainPagerAdapter mAdapetr = new MainPagerAdapter(getSupportFragmentManager(), fragments);
body.setAdapter(mAdapetr);
body.setCurrentItem(0);
footer.setCheckedIndex(body.getCurrentItem());
footer.setOnItemChangedListener(new CustomRadioGroup.OnItemChangedListener() {
public void onItemChanged() {
body.setCurrentItem(footer.getCheckedIndex(), false);
}
});
//footer.setItemNewsCount(1, 10);// 设置消息数量
}
示例9: initialisePaging
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
/**
* Initialise the fragments to be paged
*/
private void initialisePaging() {
List<Fragment> fragments = new Vector<Fragment>();
fragments.add(Fragment.instantiate(this, HomeFragment.class.getName()));
fragments.add(Fragment.instantiate(this, AboutGECAFragment.class.getName()));
//fragments.add(Fragment.instantiate(this, Tab3Fragment.class.getName()));
this.mPagerAdapter = new PagerAdapter(super.getSupportFragmentManager(), fragments);
//
f.setVisibility(View.GONE);
ViewPager pager = (ViewPager)super.findViewById(R.id.frame_container1);
pager.setAdapter(this.mPagerAdapter);
}
示例10: setupViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
adapter.addFragment(new SliderScheduleFragment(), "Shedule");
adapter.addFragment(new SliderClassFragment(), "Class");
adapter.addFragment(new Home_Student_Slidebar_Fragment(), "Student");
adapter.addFragment(new SliderSettingFragment(), "Setting");
viewPager.setAdapter(adapter);
}
示例11: setupViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void setupViewPager(ViewPager viewPager) {
Adapter adapter = new Adapter(getSupportFragmentManager());
adapter.addFragment(new LiveKanalerFrag(), "Live");
adapter.addFragment(new MestSeteFrag(), "Mest Sete");
adapter.addFragment(new MestSeteFrag(), "Sidste Chance");
adapter.addFragment(new MestSeteFrag(), "Favoritter");
viewPager.setAdapter(adapter);
}
示例12: initPaging
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void initPaging() {
OrdinaryTable mOrdinaryTableFragment = new OrdinaryTable();
mOrdinaryTableFragment.setContainer(allElementsContainer);
pagerAdapter = new MixedPagerAdapter(getSupportFragmentManager());
pagerAdapter.addFragment(mOrdinaryTableFragment);
viewPager = (ViewPager) findViewById(R.id.container);
if (viewPager != null) {
viewPager.setAdapter(pagerAdapter);
}
}
示例13: setupViewPager
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
private void setupViewPager(ViewPager viewPager) {
Adapter adapter = new Adapter(getSupportFragmentManager());
adapter.addFragment(new ListContentFragment(), "List");
adapter.addFragment(new TileContentFragment(), "Tile");
adapter.addFragment(new CardContentFragment(), "Card");
viewPager.setAdapter(adapter);
}
示例14: onCreateView
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
public View onCreateView(
final LayoutInflater inflater,
final @Nullable ViewGroup container,
final @Nullable Bundle savedInstanceState) {
pager = (ViewPager) inflater.inflate(R.layout.fragment_attachment_pager, container, false);
pager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.grid_spacer1));
pager.setAdapter(adapter);
return pager;
}
开发者ID:PacktPublishing,项目名称:Hands-On-Android-UI-Development,代码行数:12,代码来源:AttachmentPagerFragment.java
示例15: onCreate
import android.support.v4.view.ViewPager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.act_view_pager);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mViewPager = (ViewPager) findViewById(R.id.viewPager);
mViewPager.setOffscreenPageLimit(5);
mViewAdapter = new HDImageViewAdapter(this);
mViewPager.setAdapter(mViewAdapter);
initData();
}