當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewPager.setAdapter方法代碼示例

本文整理匯總了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());
    }
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:25,代碼來源:ScreenShotsActivity.java

示例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);
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:26,代碼來源:PickerAlbumPreviewActivity.java

示例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;
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:14,代碼來源:IntroductionFragment.java

示例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);

}
 
開發者ID:ligongzai,項目名稱:QianXun,代碼行數:19,代碼來源:HomePagerFragment.java

示例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;
}
 
開發者ID:Spencer231,項目名稱:GifImageLoader,代碼行數:9,代碼來源:ImagePagerFragment.java

示例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);
}
 
開發者ID:tranleduy2000,項目名稱:text_converter,代碼行數:16,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:xeliot,項目名稱:ChewSnap,代碼行數:9,代碼來源:MainActivity.java

示例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);// 設置消息數量

}
 
開發者ID:cowthan,項目名稱:ayo-menu,代碼行數:32,代碼來源:MainPagerActivity.java

示例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);
}
 
開發者ID:vikasdesale,項目名稱:Wings2K16,代碼行數:16,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:inteliedoit,項目名稱:thesis-project,代碼行數:9,代碼來源:Home_Activity.java

示例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);
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:9,代碼來源:NiclasHovedAkt.java

示例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);
    }
}
 
開發者ID:mikebutrimov,項目名稱:ChemistryEasy,代碼行數:11,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:TORU0239,項目名稱:android-design-library-master,代碼行數:8,代碼來源:MainActivity.java

示例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();
}
 
開發者ID:EvilBT,項目名稱:HDImageView,代碼行數:15,代碼來源:ViewPagerActivity.java


注:本文中的android.support.v4.view.ViewPager.setAdapter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。