use of android.support.v13.app.FragmentPagerAdapter in project BoomMenu by Nightonke.
the class FragmentActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragment);
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
assert viewPager != null;
viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
return new BMBFragment().position(position);
}
@Override
public int getCount() {
return 50;
}
});
}
use of android.support.v13.app.FragmentPagerAdapter in project AndroidAutoLayout by hongyangAndroid.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("标题");
setSupportActionBar(toolbar);
mTabLayout = (TabLayout) findViewById(R.id.id_tablayout);
mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
return new SimpleFragment();
}
@Override
public int getCount() {
return 2;
}
@Override
public CharSequence getPageTitle(int position) {
return "Page " + position;
}
});
mTabLayout.setupWithViewPager(mViewPager);
}
use of android.support.v13.app.FragmentPagerAdapter in project StatusBarUtil by laobie.
the class UseInFragmentActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_use_in_fragment);
mVpHome = (ViewPager) findViewById(R.id.vp_home);
mBottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
mBottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_favorite, "One")).addItem(new BottomNavigationItem(R.drawable.ic_gavel, "Two")).addItem(new BottomNavigationItem(R.drawable.ic_grade, "Three")).addItem(new BottomNavigationItem(R.drawable.ic_group_work, "Four")).initialise();
mBottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
@Override
public void onTabSelected(int position) {
mVpHome.setCurrentItem(position);
}
@Override
public void onTabUnselected(int position) {
}
@Override
public void onTabReselected(int position) {
}
});
mFragmentList.add(new ImageFragment());
mFragmentList.add(new SimpleFragment());
mFragmentList.add(new SimpleFragment());
mFragmentList.add(new SimpleFragment());
mVpHome.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mBottomNavigationBar.selectTab(position);
switch(position) {
case 0:
break;
default:
Random random = new Random();
int color = 0xff000000 | random.nextInt(0xffffff);
if (mFragmentList.get(position) instanceof SimpleFragment) {
((SimpleFragment) mFragmentList.get(position)).setTvTitleBackgroundColor(color);
}
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mVpHome.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
});
}
use of android.support.v13.app.FragmentPagerAdapter in project quickstart-android by firebase.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create the adapter that will return a fragment for each section
mPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
private final Fragment[] mFragments = new Fragment[] { new RecentPostsFragment(), new MyPostsFragment(), new MyTopPostsFragment() };
private final String[] mFragmentNames = new String[] { getString(R.string.heading_recent), getString(R.string.heading_my_posts), getString(R.string.heading_my_top_posts) };
@Override
public Fragment getItem(int position) {
return mFragments[position];
}
@Override
public int getCount() {
return mFragments.length;
}
@Override
public CharSequence getPageTitle(int position) {
return mFragmentNames[position];
}
};
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.container);
mViewPager.setAdapter(mPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(mViewPager);
// Button launches NewPostActivity
findViewById(R.id.fab_new_post).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, NewPostActivity.class));
}
});
}
use of android.support.v13.app.FragmentPagerAdapter in project leo-app by LCA311.
the class WrapperQRActivity method onCreate.
/* private ZXingScannerView scV;
public static Button scan;
private final int MY_PERMISSIONS_REQUEST_USE_CAMERA = 0;
private boolean runningScan; */
@Override
protected void onCreate(Bundle savedInstanceState) {
/* super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wrapper_qr); */
//---- START TOOLBAR ---- //
Toolbar myToolbar = (Toolbar) findViewById(R.id.toolbar);
// runningScan = false;
setSupportActionBar(myToolbar);
//If it's stupid, but it works it's not stupid
getSupportActionBar().setTitle(Html.fromHtml("<font color=\"#ffffff\">" + getString(R.string.toolbar_title) + "</font>"));
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
//---- ENDE TOOLBAR ---- //
//---- START TABS ---- //
mViewPager = (ViewPager) findViewById(R.id.pager);
FragmentPagerAdapter adapt = new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
if (position == 0)
//QRActivity ist ein Fragment trotz des Namens
return new QRActivity();
else
//ScanActivity ist ein Fragment trotz des Namens
return new ScanActivity();
}
@Override
public int getCount() {
return 2;
}
@Override
public CharSequence getPageTitle(int position) {
if (position == 0)
return getString(R.string.toolbar_qr);
else
return getString(R.string.toolbar_scan);
}
};
mViewPager.setAdapter(adapt);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tablayout);
tabLayout.setupWithViewPager(mViewPager);
//---- ENDE TABS ---- //
/* sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
sqlh = new SQLiteHandler(getApplicationContext());
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
scan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
scan();
}
});
}
}, 100); */
}
Aggregations