Search in sources :

Example 21 with ViewPager

use of androidx.viewpager.widget.ViewPager in project PagerBottomTabStrip by tyzlmjj.

the class Custom2Activity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_horizontal);
    PageNavigationView tab = findViewById(R.id.tab);
    NavigationController navigationController = tab.custom().addItem(newItem_test(R.drawable.ic_restore_gray_24dp, R.drawable.ic_restore_teal_24dp)).addItem(newItem(R.drawable.ic_favorite_gray_24dp, R.drawable.ic_favorite_teal_24dp)).addItem(newItem(R.drawable.ic_nearby_gray_24dp, R.drawable.ic_nearby_teal_24dp)).build();
    ViewPager viewPager = findViewById(R.id.viewPager);
    viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), navigationController.getItemCount()));
    // 自动适配ViewPager页面切换
    navigationController.setupWithViewPager(viewPager);
}
Also used : NavigationController(me.majiajie.pagerbottomtabstrip.NavigationController) PageNavigationView(me.majiajie.pagerbottomtabstrip.PageNavigationView) MyViewPagerAdapter(me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter) ViewPager(androidx.viewpager.widget.ViewPager)

Example 22 with ViewPager

use of androidx.viewpager.widget.ViewPager in project PagerBottomTabStrip by tyzlmjj.

the class HideActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hide);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    PageNavigationView pageBottomTabLayout = findViewById(tab);
    mNavigationController = pageBottomTabLayout.material().addItem(R.drawable.ic_restore_teal_24dp, "Recents").addItem(R.drawable.ic_favorite_teal_24dp, "Favorites").addItem(R.drawable.ic_nearby_teal_24dp, "Nearby").build();
    ViewPager viewPager = findViewById(R.id.viewPager);
    viewPager.setAdapter(new TestViewPagerAdapter(getSupportFragmentManager()));
    mNavigationController.setupWithViewPager(viewPager);
}
Also used : PageNavigationView(me.majiajie.pagerbottomtabstrip.PageNavigationView) ViewPager(androidx.viewpager.widget.ViewPager) Toolbar(androidx.appcompat.widget.Toolbar)

Example 23 with ViewPager

use of androidx.viewpager.widget.ViewPager in project PagerBottomTabStrip by tyzlmjj.

the class VerticalActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_vertical);
    PageNavigationView pageBottomTabLayout = findViewById(tab);
    mNavigationController = pageBottomTabLayout.material().addItem(R.drawable.ic_ondemand_video_black_24dp, "Movies & TV", testColors[0]).addItem(R.drawable.ic_audiotrack_black_24dp, "Music", testColors[1]).addItem(R.drawable.ic_book_black_24dp, "Books", testColors[2]).addItem(R.drawable.ic_news_black_24dp, "Newsstand", testColors[3]).enableVerticalLayout().build();
    ViewPager viewPager = findViewById(R.id.viewPager);
    viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), mNavigationController.getItemCount()));
    // 自动适配ViewPager页面切换
    mNavigationController.setupWithViewPager(viewPager);
    // 也可以设置Item选中事件的监听
    mNavigationController.addTabItemSelectedListener(new OnTabItemSelectedListener() {

        @Override
        public void onSelected(int index, int old) {
            Log.i("asd", "selected: " + index + " old: " + old);
        }

        @Override
        public void onRepeat(int index) {
            Log.i("asd", "onRepeat selected: " + index);
        }
    });
    // 设置消息圆点
    mNavigationController.setMessageNumber(0, 8);
    mNavigationController.setHasMessage(3, true);
}
Also used : OnTabItemSelectedListener(me.majiajie.pagerbottomtabstrip.listener.OnTabItemSelectedListener) PageNavigationView(me.majiajie.pagerbottomtabstrip.PageNavigationView) MyViewPagerAdapter(me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter) ViewPager(androidx.viewpager.widget.ViewPager)

Example 24 with ViewPager

use of androidx.viewpager.widget.ViewPager in project PagerBottomTabStrip by tyzlmjj.

the class VerticalCustomActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_vertical_custom);
    PageNavigationView pageNavigationView = findViewById(R.id.tab);
    mNavigationController = pageNavigationView.custom().addItem(new OnlyTextTab(this, "A")).addItem(new OnlyTextTab(this, "B")).addItem(new OnlyTextTab(this, "C")).addItem(new OnlyTextTab(this, "D")).addItem(new OnlyTextTab(this, "E")).addItem(new OnlyTextTab(this, "F")).addItem(new OnlyTextTab(this, "G")).addItem(new OnlyTextTab(this, "H")).addItem(new OnlyTextTab(this, "I")).addItem(new OnlyTextTab(this, "J")).addItem(new OnlyTextTab(this, "K")).addItem(new OnlyTextTab(this, "L")).addItem(new OnlyTextTab(this, "M")).addItem(new OnlyTextTab(this, "N")).addItem(new OnlyTextTab(this, "O")).enableVerticalLayout().build();
    ViewPager viewPager = findViewById(R.id.viewPager);
    viewPager.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager(), mNavigationController.getItemCount()));
    // 自动适配ViewPager页面切换
    mNavigationController.setupWithViewPager(viewPager);
}
Also used : PageNavigationView(me.majiajie.pagerbottomtabstrip.PageNavigationView) OnlyTextTab(me.majiajie.pagerbottomtabstriptest.custom.OnlyTextTab) MyViewPagerAdapter(me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter) ViewPager(androidx.viewpager.widget.ViewPager)

Example 25 with ViewPager

use of androidx.viewpager.widget.ViewPager in project ExoPlayer by google.

the class TrackSelectionDialog method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View dialogView = inflater.inflate(R.layout.track_selection_dialog, container, false);
    TabLayout tabLayout = dialogView.findViewById(R.id.track_selection_dialog_tab_layout);
    ViewPager viewPager = dialogView.findViewById(R.id.track_selection_dialog_view_pager);
    Button cancelButton = dialogView.findViewById(R.id.track_selection_dialog_cancel_button);
    Button okButton = dialogView.findViewById(R.id.track_selection_dialog_ok_button);
    viewPager.setAdapter(new FragmentAdapter(getChildFragmentManager()));
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setVisibility(tabFragments.size() > 1 ? View.VISIBLE : View.GONE);
    cancelButton.setOnClickListener(view -> dismiss());
    okButton.setOnClickListener(view -> {
        onClickListener.onClick(getDialog(), DialogInterface.BUTTON_POSITIVE);
        dismiss();
    });
    return dialogView;
}
Also used : Button(android.widget.Button) TabLayout(com.google.android.material.tabs.TabLayout) View(android.view.View) TrackSelectionView(com.google.android.exoplayer2.ui.TrackSelectionView) ViewPager(androidx.viewpager.widget.ViewPager) SelectionOverride(com.google.android.exoplayer2.trackselection.DefaultTrackSelector.SelectionOverride)

Aggregations

ViewPager (androidx.viewpager.widget.ViewPager)68 View (android.view.View)24 Intent (android.content.Intent)12 TabLayout (com.google.android.material.tabs.TabLayout)12 Toolbar (androidx.appcompat.widget.Toolbar)11 ViewGroup (android.view.ViewGroup)9 TextView (android.widget.TextView)9 ColorPreferences (me.ccrama.redditslide.Visuals.ColorPreferences)9 ImageView (android.widget.ImageView)8 PageNavigationView (me.majiajie.pagerbottomtabstrip.PageNavigationView)8 Bundle (android.os.Bundle)6 PagerAdapter (androidx.viewpager.widget.PagerAdapter)6 MyViewPagerAdapter (me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter)6 CircleIndicator (me.relex.circleindicator.CircleIndicator)6 LayoutInflater (android.view.LayoutInflater)5 Button (android.widget.Button)5 SamplePagerAdapter (me.relex.circleindicator.sample.SamplePagerAdapter)5 LinearInterpolator (android.view.animation.LinearInterpolator)4 NonNull (androidx.annotation.NonNull)4 FragmentStatePagerAdapter (androidx.fragment.app.FragmentStatePagerAdapter)4