Java Code Examples for android.support.v4.view.ViewPager#setOffscreenPageLimit()

The following examples show how to use android.support.v4.view.ViewPager#setOffscreenPageLimit() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NestedScrollingActivity.java    From PullRefreshView with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nestedscrolling);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ArrayList<Fragment> fragments = new ArrayList<>();
    fragments.add(new Fragment0());
    fragments.add(new Fragment1());
    fragments.add(new Fragment2());
    fragments.add(new Fragment3());
    fragments.add(new Fragment4());
    MyFragmentPagerAdapter myFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), fragments);
    viewPager = (ViewPager) findViewById(R.id.viewpager);
    viewPager.setOffscreenPageLimit(2);
    viewPager.setAdapter(myFragmentPagerAdapter);
}
 
Example 2
Source File: MainActivity.java    From android-kline with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TabLayout tabLayout = findViewById(R.id.tab);
    final ViewPager viewPager = findViewById(R.id.view_pager);
    Fragment[] fragments = {TimeLineChartFragment.newInstance(1), FiveDayChartFragment.newInstance(),
            KLineChartFragment.newInstance(1), KLineChartFragment.newInstance(7),
            KLineChartFragment.newInstance(30)};
    String[] titles = {"分时图", "5Day", "日K", "周K", "月"};
    viewPager.setOffscreenPageLimit(fragments.length);
    viewPager.setAdapter(new SimpleFragmentPagerAdapter(getSupportFragmentManager(), fragments, titles));
    tabLayout.setupWithViewPager(viewPager);
    findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FullScreenChartActivity.launch(MainActivity.this, viewPager.getCurrentItem());
        }
    });
}
 
Example 3
Source File: MainActivity.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mViewPager = (ViewPager) findViewById(R.id.view_pager);
    final com.actionbarsherlock.app.ActionBar bar = getSupportActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    BarFragment barFrag = new BarFragment();
    LineFragment lineFragment = new LineFragment();
    PieFragment pieFragment = new PieFragment();

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText("Line"),
            LineFragment.class, null, lineFragment);
    mTabsAdapter.addTab(bar.newTab().setText("Pie"),
            PieFragment.class, null, pieFragment);
    mTabsAdapter.addTab(bar.newTab().setText("Bar"),
            BarFragment.class, null, barFrag);


    mViewPager.setOffscreenPageLimit(mTabsAdapter.getCount()-1);
}
 
Example 4
Source File: MainActivity.java    From text_converter with GNU General Public License v3.0 6 votes vote down vote up
private void bindView() {
    mCoordinatorLayout = findViewById(R.id.container);
    String text = getTextFromAnotherApp();

    ViewPager viewPager = findViewById(R.id.view_pager);
    PagerAdapter 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);

    mDrawerLayout = findViewById(R.id.drawer_layout);
    mNavigationView = findViewById(R.id.nav_view);
    ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
            mToolbar, R.string.desc_open_drawer, R.string.desc_close_drawer);
    mDrawerLayout.addDrawerListener(drawerToggle);
    drawerToggle.syncState();
    mNavigationView.setNavigationItemSelectedListener(this);
}
 
Example 5
Source File: NewsFragment.java    From SprintNBA with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeViews(String[] names) {

    scrollIndicatorView = (ScrollIndicatorView) findViewById(R.id.nba_news_indicator);
    scrollIndicatorView.setBackgroundColor(ContextCompat.getColor(mActivity, R.color.colorPrimary));
    scrollIndicatorView.setScrollBar(new DrawableBar(mActivity, R.drawable.round_border_white_selector, ScrollBar.Gravity.CENTENT_BACKGROUND) {
        @Override
        public int getHeight(int tabHeight) {
            return tabHeight - DimenUtils.dpToPxInt(12);
        }

        @Override
        public int getWidth(int tabWidth) {
            return tabWidth - DimenUtils.dpToPxInt(12);
        }
    });
    scrollIndicatorView.setSplitAuto(true);
    // 设置滚动监听
    scrollIndicatorView.setOnTransitionListener(new OnTransitionTextListener().setColor(getResources().getColor(R.color.colorPrimary), Color.WHITE));

    ViewPager viewPager = (ViewPager) findViewById(R.id.nba_news_viewPager);
    viewPager.setOffscreenPageLimit(names.length);
    indicatorViewPager = new IndicatorViewPager(scrollIndicatorView, viewPager);
    indicatorViewPager.setAdapter(new VPNewsAdapter(mActivity, names, getChildFragmentManager()));
}
 
Example 6
Source File: BlogViewPagerFragment.java    From Cotable with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater,
                         @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_viewpager, container,
            false);
    mTabStrip = (PagerSlidingTabStrip) view.findViewById(R.id.tabs);
    mViewPager = (ViewPager) view.findViewById(R.id.main_tab_pager);

    if (mViewPager.getAdapter() == null &&
            mTabAdapter == null) {
        mTabAdapter = new BlogTabPagerAdapter(getChildFragmentManager(),
                getActivity(), mViewPager);
    }
    mViewPager.setOffscreenPageLimit(mTabAdapter.getCacheCount());
    mViewPager.setAdapter(mTabAdapter);
    mViewPager.setOnPageChangeListener(this);
    mTabStrip.setViewPager(mViewPager);

    return view;
}
 
Example 7
Source File: MainActivity.java    From GankMeizhi with Apache License 2.0 5 votes vote down vote up
private void setupViewPager(ViewPager viewPager) {
    viewPager.setOffscreenPageLimit(4);
    Adapter adapter = new Adapter(getSupportFragmentManager());

    addTab(adapter, GankFragment.FRAG_TYPE_ALL, getResources().getString(R.string.nav_all));
    addTab(adapter, GankFragment.FRAG_TYPE_MEIZHI, getResources().getString(R.string.nav_mm));
    addTab(adapter, GankFragment.FRAG_TYPE_ANDROID, getResources().getString(R.string.nav_android));
    addTab(adapter, GankFragment.FRAG_TYPE_IOS, getResources().getString(R.string.nav_ios));

    viewPager.setAdapter(adapter);
}
 
Example 8
Source File: DownloadsActivity.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_downloads);

    initToolBar();

    SupportedDownloads.KernelContent content = new SupportedDownloads.KernelContent(getIntent().getStringExtra(JSON_INTENT));
    getSupportActionBar().setTitle(Utils.htmlFrom(content.getName()).toString());

    final ViewPager viewPager = findViewById(R.id.viewpager);

    LinkedHashMap<String, Fragment> items = new LinkedHashMap<>();

    List<SupportedDownloads.KernelContent.Feature> features = content.getFeatures();
    List<SupportedDownloads.KernelContent.Download> downloads = content.getDownloads();

    if (content.getShortDescription() != null && content.getLongDescription() != null) {
        items.put(getString(R.string.about), AboutFragment.newInstance(content));
    }

    if (features.size() > 0) {
        items.put(getString(R.string.features), FeaturesFragment.newInstance(features));
    }

    if (downloads.size() > 0) {
        items.put(getString(R.string.downloads), DownloadKernelFragment.newInstance(downloads));
    }

    viewPager.setOffscreenPageLimit(items.size());
    PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager(), items);
    viewPager.setAdapter(pagerAdapter);

    TabLayout tabLayout = findViewById(R.id.tablayout);
    tabLayout.setupWithViewPager(viewPager);

    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
}
 
Example 9
Source File: Main.java    From isu with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FragmentActivityWeakReference = new WeakReference < FragmentActivity > (this);

    setContentView(R.layout.main);
    String cmiyc = Tools.readString("cmiyc", null, this);
    if (cmiyc == null || cmiyc.isEmpty())
        Tools.saveString("cmiyc", Tools.random4(), this);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setActionBar(toolbar);

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(new TabsPagerAdapter(getFragmentManager()));
    viewPager.setOffscreenPageLimit(getTitles().length);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
    tabLayout.setupWithViewPager(viewPager);

    mMasked = (TextView) findViewById(R.id.masked);

    if (!Tools.appId(getApplicationContext()))
        mMasked.setText(getString(R.string.masked));

    mAbout = (TextView) findViewById(R.id.about);
    mAbout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(getApplicationContext(), AboutActivity.class);
            startActivity(myIntent);
        }
    });
    check_writeexternalstorage();
}
 
Example 10
Source File: TabbedSocialMediaActivity.java    From socialmediasignup with MIT License 5 votes vote down vote up
protected void setupViewPager(ViewPager viewPager, List<SocialMediaItem> items) {
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());

    for (SocialMediaItem item : items)
        adapter.addFragment(SocialMediaFragment.newInstance(item.getSocialMediaType()), item.getSocialMediaType().getValue());

    viewPager.setOffscreenPageLimit(items.size());
    viewPager.setAdapter(adapter);
}
 
Example 11
Source File: PhotoViewerActivity.java    From glimmr with Apache License 2.0 5 votes vote down vote up
private void initViewPager(int startIndex, boolean fetchExtraInfo) {
    mAdapter = new PhotoViewerPagerAdapter(getSupportFragmentManager(), fetchExtraInfo);
    mAdapter.onPageSelected(startIndex);
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);
    mPager.setOnPageChangeListener(mAdapter);
    mPager.setCurrentItem(startIndex);
    mPager.setOffscreenPageLimit(2);
    mPager.setPageTransformer(true, new CardTransformer(0.7f));
}
 
Example 12
Source File: MovieCoverFanartBrowser.java    From Mizuu with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	MizuuApplication.setupTheme(this);

       if (MizLib.hasLollipop())
           getSupportActionBar().setElevation(0);

       mTmdbId = getIntent().getExtras().getString("tmdbId");
       mCollectionId = getIntent().getExtras().getString("collectionId");
       mToolbarColor = getIntent().getExtras().getInt(IntentKeys.TOOLBAR_COLOR);
	mTmdbApiKey = MizLib.getTmdbApiKey(this);

       mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
       mProgressBar.setVisibility(View.VISIBLE);

       mViewPager = (ViewPager) findViewById(R.id.awesomepager);
       mViewPager.setOffscreenPageLimit(2);
       mViewPager.setPageMargin(MizLib.convertDpToPixels(this, 16));

       mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
       mTabs.setVisibility(View.GONE);

	if (savedInstanceState != null) {
           mJson = savedInstanceState.getString("json", "");
           mBaseUrl = savedInstanceState.getString("baseUrl");
           mCollection = savedInstanceState.getString("collection");
		setupActionBarStuff();

           mViewPager.setCurrentItem(savedInstanceState.getInt("tab", 0));
	} else {
		new MovieLoader(getApplicationContext()).execute(mTmdbId, mCollectionId);
	}
}
 
Example 13
Source File: MovieSlideTab.java    From moviedb-android with Apache License 2.0 5 votes vote down vote up
/**
 * Inflates the {@link android.view.View} which will be displayed by this {@link Fragment}, from the app's
 * resources.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    View view = inflater.inflate(R.layout.moviepager, container, false);

    // Get the ViewPager and set it's PagerAdapter so that it can display items
    adapter = new MovieSlideAdapter(getFragmentManager(), getResources());
    mViewPager = (ViewPager) view.findViewById(R.id.moviePager);
    mViewPager.setOffscreenPageLimit(1);
    mViewPager.setAdapter(adapter);

    // Give the SlidingTabLayout the ViewPager, this must be done AFTER the ViewPager has had
    // it's PagerAdapter set.
    mSlidingTabLayout = (SlidingTabLayout) view.findViewById(R.id.sliding_tabs);
    mSlidingTabLayout.setViewPager(mViewPager);
    onPageChangeSelected = new onPageChangeSelected();
    activity = ((MainActivity) getActivity());
    mSlidingTabLayout.setOnPageChangeListener(onPageChangeSelected);
    mSlidingTabLayout.setSelectedIndicatorColors(ContextCompat.getColor(activity, R.color.tabSelected));
    phone = getResources().getBoolean(R.bool.portrait_only);
    scale = getResources().getDisplayMetrics().density;
    if (phone) {
        hideThreshold = (int) (-105 * scale);
        minThreshold = (int) (-49 * scale);
    } else {
        hideThreshold = (int) (-100 * scale);
        minThreshold = (int) (-42 * scale);
    }
    return view;
}
 
Example 14
Source File: MainActivity.java    From Bookster with Apache License 2.0 5 votes vote down vote up
private void initView() {
    getWindow().setBackgroundDrawable(null);
    addpage(new AiXiaFragment(), "爱下");
    addpage(new ZhiXuanFragment(), "知轩藏书");
    addpage(new ZhouDuFragment(), "周读");
    addpage(new ShuYuZheFragment(), "书语者");
    addpage(new DongManZhiJiaFragment(), "动漫之家");
    addpage(new M360DFragment(), "360℃");
    addpage(new XiaoShuWuFragment(), "我的小书屋");
    addpage(new QiShuFragment(), "奇书");
    addpage(new BlahFragment(), "blah");

    ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
    final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    mPagerAdapter = new PagerAdapter(getSupportFragmentManager(), fragments, titles);
    viewPager.setAdapter(mPagerAdapter);
    viewPager.setOffscreenPageLimit(fragments.size());
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            searchView.findFocus();
            mPagerAdapter.setTop(tabLayout.getSelectedTabPosition());
        }
    });

    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", false)) {
        tabLayout.setSelectedTabIndicatorColor(getResources().getColor(R.color.DarkColor));
        tabLayout.setTabTextColors(tabLayout.getTabTextColors().getDefaultColor(), getResources().getColor(R.color.DarkColor));
    }
}
 
Example 15
Source File: AppViewPagerActivity.java    From browser with GNU General Public License v2.0 5 votes vote down vote up
private void initViewPager() {
	mViewPager = (ViewPager)findViewById(R.id.mViewPager);
	mAdapetr = new BaseFragmentPagerAdapter(
			getSupportFragmentManager());
	mViewPager.setOffscreenPageLimit(1);
	mViewPager.setAdapter(mAdapetr);
	mViewPager.setOnPageChangeListener(pageListener);
}
 
Example 16
Source File: Activity3.java    From chameleon with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity3);
    ViewPager viewPager = findViewById(R.id.viewpager);
    viewPager.setOffscreenPageLimit(2);
    mData.add(new Fragment1());
    mData.add(new Fragment2());
    mData.add(new Fragment4());
    viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager()));
}
 
Example 17
Source File: MainActivity.java    From 500px-guideview with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
    setContentView(R.layout.activity_main);
    setFullscreen();

    fragment00 = new GuideFragment();
    fragment01 = new GuideFragment();
    fragment02 = new GuideFragment();
    fragment03 = new GuideFragment();

    fragmentList.add(fragment00);
    fragmentList.add(fragment01);
    fragmentList.add(fragment02);
    fragmentList.add(fragment03);


    viewpager = (ViewPager) findViewById(R.id.viewpager);
    iv_device = (ImageView) findViewById(R.id.iv_device);
    iv_final_photo = (ImageView) findViewById(R.id.iv_final_photo);
    tv_avatar_you = (TextView) findViewById(R.id.tv_avatar_you);
    tv_register = (TextView) findViewById(R.id.tv_register);

    blurringView = (BlurringView) findViewById(R.id.blurringView);

    ll_rows = (LinearLayout) findViewById(R.id.ll_rows);
    ll_comments = (LinearLayout) findViewById(R.id.ll_comments);

    iv_initial_phone = (ImageView) findViewById(R.id.iv_initial_phone);

    View blurredView = findViewById(R.id.blurredView);
    blurringView.setBlurredView(blurredView);
    
    //创建adapter
    GuideAdapter adapter = new GuideAdapter(getSupportFragmentManager());
    //设置viewpager缓存页数,默认的缓存一页,因为引导页共有4页,
    //所以设置缓存3页,这样所以page在滑动过程中不会重新创建
    viewpager.setOffscreenPageLimit(3);
    viewpager.setAdapter(adapter);
    viewpager.setPageTransformer(true, new HKTransformer());
}
 
Example 18
Source File: SubCategoryActivity.java    From wallpaper with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	currentPageSubLatest = 0;
	currentPageSubRecommended = 0;
	currentPageHottest = 0;
	currentPage = 0;
	isFromRefreshDataSubLatest = true;
	isFromRefreshDataSubRecommended = true;
	isFromRefreshDataHottest = true;
	latestGroups = new ArrayList<Group>();
	recommendedGroups = new ArrayList<Group>();
	hottestGroups = new ArrayList<Group>();
	setContentView(R.layout.activity_subcategory);

	subcategory_title_textview = (TextView) findViewById(R.id.subcategory_title_textview);
	subcategoryBackImage = (ImageView) findViewById(R.id.subcategory_back_image);
	subcategoryBackImage.setOnClickListener(this);

	pager = (ViewPager) findViewById(R.id.pager);
	pager.setOffscreenPageLimit(2);
	fragments = new ArrayList<Fragment>();

	SubLatestFragment sublatestFragment = new SubLatestFragment();
	SubRecommendedFragment subrecommendedFragment = new SubRecommendedFragment();
	HottestFragment hottestfragment = new HottestFragment();
	fragments.add(sublatestFragment);
	fragments.add(subrecommendedFragment);
	fragments.add(hottestfragment);

	latestButton = (RadioButton) findViewById(R.id.radio_sub_latest);
	latestButton.setOnClickListener(this);
	recommendedButton = (RadioButton) findViewById(R.id.radio_sub_recommended);
	recommendedButton.setOnClickListener(this);
	hottestButton = (RadioButton) findViewById(R.id.radio_hottest);
	hottestButton.setOnClickListener(this);

	mAdapter = new ViewPagerAdapter(getSupportFragmentManager(), fragments);
	pager.setAdapter(mAdapter);
	menu = new SlidingMenu(this);
	menu.setMode(SlidingMenu.LEFT);
	menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
	menu.setShadowWidthRes(R.dimen.shadow_width);
	menu.setShadowDrawable(R.drawable.slidingmenu_shadow);
	menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
	menu.setFadeDegree(0.35f);
	menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
	menu.setMenu(R.layout.layout_menu);
	menu.setMode(SlidingMenu.LEFT);
	menu.setMenu(R.layout.layout_menu);
	long screenWidth = WallWrapperEnvConfigure.getScreenWidth();
	menu.setBehindWidth((int) (screenWidth * 0.7));

	pager.setOnPageChangeListener(this);

	menuListView = (ListView) menu.getMenu().findViewById(R.id.menu_listview);
	menuListView.setAdapter(new MenuListViewAdapter(this));
	menuListView.setOnItemClickListener(this);
}
 
Example 19
Source File: EmojiViewExtra.java    From Yahala-Messenger with MIT License 4 votes vote down vote up
private void init() {
    setOrientation(LinearLayout.VERTICAL);
    loadRecents();
    setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{Color.parseColor("#FF373737"), Color.parseColor("#FF575757"), Color.parseColor("#FF666666")}));


    emojiPagerAdapter = new EmojiPagerAdapter(getContext(), EmojiManager.getInstance().categories);
    pager = new ViewPager(getContext());
    pager.setOffscreenPageLimit(5);
    pager.setAdapter(emojiPagerAdapter);
    FileLog.e("EmojiManager.emojiGroups", "" + EmojiManager.getInstance().categories.size());
    PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(false);
    tabs.setMinimumWidth(OSUtilities.dp(50));
    tabs.setTabPaddingLeftRight(OSUtilities.dp(10));
    tabs.setIndicatorHeight(3);
    //tabs.setTabBackground(Color.parseColor("#FF3f9fe0"));
    tabs.setTabBackground(R.drawable.bar_selector_main);


    tabs.setIndicatorColor(Color.parseColor("#FFffffff"));
    tabs.setDividerColor(Color.parseColor("#ff222222"));
    tabs.setUnderlineHeight(2);
    tabs.setUnderlineColor(Color.parseColor("#ff373737"));

    //tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            if (EmojiViewExtra.this.listener != null) {
                EmojiViewExtra.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView, new LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT));
   /* recentsWrap = new FrameLayout(getContext());
    recentsWrap.addView(views.get(0));
    TextView localTextView = new TextView(getContext());
    localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
    localTextView.setTextSize(18.0f);
    localTextView.setTextColor(-7829368);
    localTextView.setGravity(17);
    recentsWrap.addView(localTextView);
    views.get(0).setEmptyView(localTextView);*/
    addView(localLinearLayout, new LayoutParams(-1, OSUtilities.dpf(48.0f)));

    addView(pager);

    if (!EmojiManager.getInstance().categoriesDict.containsKey("recents") || EmojiManager.getInstance().categoriesDict.get("recents").emojis.size() == 0) {
        pager.setCurrentItem(1);
    }
}
 
Example 20
Source File: SubCategoryActivity.java    From wallpaper with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	currentPageSubLatest = 0;
	currentPageSubRecommended = 0;
	currentPageHottest = 0;
	currentPage = 0;
	isFromRefreshDataSubLatest = true;
	isFromRefreshDataSubRecommended = true;
	isFromRefreshDataHottest = true;
	latestGroups = new ArrayList<Group>();
	recommendedGroups = new ArrayList<Group>();
	hottestGroups = new ArrayList<Group>();
	setContentView(R.layout.activity_subcategory);

	subcategory_title_textview = (TextView) findViewById(R.id.subcategory_title_textview);
	subcategoryBackImage = (ImageView) findViewById(R.id.subcategory_back_image);
	subcategoryBackImage.setOnClickListener(this);

	pager = (ViewPager) findViewById(R.id.pager);
	pager.setOffscreenPageLimit(2);
	fragments = new ArrayList<Fragment>();

	SubLatestFragment sublatestFragment = new SubLatestFragment();
	SubRecommendedFragment subrecommendedFragment = new SubRecommendedFragment();
	HottestFragment hottestfragment = new HottestFragment();
	fragments.add(sublatestFragment);
	fragments.add(subrecommendedFragment);
	fragments.add(hottestfragment);

	latestButton = (RadioButton) findViewById(R.id.radio_sub_latest);
	latestButton.setOnClickListener(this);
	recommendedButton = (RadioButton) findViewById(R.id.radio_sub_recommended);
	recommendedButton.setOnClickListener(this);
	hottestButton = (RadioButton) findViewById(R.id.radio_hottest);
	hottestButton.setOnClickListener(this);

	mAdapter = new ViewPagerAdapter(getSupportFragmentManager(), fragments);
	pager.setAdapter(mAdapter);
	menu = new SlidingMenu(this);
	menu.setMode(SlidingMenu.LEFT);
	menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
	menu.setShadowWidthRes(R.dimen.shadow_width);
	menu.setShadowDrawable(R.drawable.slidingmenu_shadow);
	menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
	menu.setFadeDegree(0.35f);
	menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
	menu.setMenu(R.layout.layout_menu);
	menu.setMode(SlidingMenu.LEFT);
	menu.setMenu(R.layout.layout_menu);
	long screenWidth = WallWrapperEnvConfigure.getScreenWidth();
	menu.setBehindWidth((int) (screenWidth * 0.7));

	pager.setOnPageChangeListener(this);

	menuListView = (ListView) menu.getMenu().findViewById(R.id.menu_listview);
	menuListView.setAdapter(new MenuListViewAdapter(this));
	menuListView.setOnItemClickListener(this);
}