use of android.support.v4.app.Fragment in project Android-skin-support by ximsfei.
the class MainActivity method configFragments.
private void configFragments() {
List<Fragment> list = new ArrayList<>();
list.add(new FirstFragment());
list.add(new MiddleFragment());
list.add(new LastFragment());
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
viewPager.setAdapter(new TabFragmentPagerAdapter(getSupportFragmentManager(), list));
List<String> listTitle = new ArrayList<>();
listTitle.add("系统组件");
listTitle.add("自定义View");
listTitle.add("第三方库控件");
mTabFragmentPagerAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager(), list, listTitle);
viewPager.setAdapter(mTabFragmentPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
}
use of android.support.v4.app.Fragment in project Android-skin-support by ximsfei.
the class MaterialDesignActivity method configFragments.
private void configFragments() {
List<Fragment> list = new ArrayList<>();
list.add(new MDFirstFragment());
// list.add(new MiddleFragment());
// list.add(new LastFragment());
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
List<String> listTitle = new ArrayList<>();
listTitle.add("系统组件");
// listTitle.add("自定义View");
// listTitle.add("第三方库控件");
mTabFragmentPagerAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager(), list, listTitle);
viewPager.setAdapter(mTabFragmentPagerAdapter);
tabLayout.setupWithViewPager(viewPager);
}
use of android.support.v4.app.Fragment in project PocketHub by pockethub.
the class MainActivity method switchFragment.
@VisibleForTesting
void switchFragment(Fragment fragment, User organization) {
if (organization != null) {
Bundle args = new Bundle();
args.putParcelable("org", organization);
fragment.setArguments(args);
}
FragmentManager manager = getSupportFragmentManager();
manager.beginTransaction().replace(R.id.container, fragment).commit();
drawerLayout.closeDrawer(GravityCompat.START);
}
use of android.support.v4.app.Fragment in project PocketHub by pockethub.
the class PagerFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
Fragment fragment = getFragment();
if (fragment != null) {
fragment.onCreateOptionsMenu(menu, getActivity().getMenuInflater());
}
super.onCreateOptionsMenu(menu, inflater);
}
use of android.support.v4.app.Fragment in project carat by amplab.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CaratApplication.setMain(this);
tracker = Tracker.getInstance();
// track user clicks (taps)
tracker.trackUser("caratstarted");
if (!CaratApplication.isInternetAvailable()) {
EnableInternetDialogFragment dialog = new EnableInternetDialogFragment();
dialog.show(getSupportFragmentManager(), "dialog");
}
/*
* Activity.getWindow.requestFeature() should get invoked only before
* setContentView(), otherwise it will cause an app crash The progress
* bar doesn't get displayed when there is no update in progress
*/
getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
// Log.d(TAG, "about to set the layout");
setContentView(R.layout.activity_main);
ActionBar actionBar = getSupportActionBar();
setTitleNormal();
// read and load the preferences specified in our xml preference file
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
// Log.d(TAG, "about to initialize fragments");
preInittializeFragments();
// Log.d(TAG, "done with fragment initialization");
/*
* Before using the field "fullVersion", first invoke setTitleNormal()
* or setFullVersion() to set this field
*/
mDrawerItems = getResources().getStringArray(R.array.drawer_items);
List<Item> items = new ArrayList<Item>();
// items.add(new NavDrawerListHeader("Main"));
items.add(new ListItem(mDrawerItems[0]));
items.add(new ListItem(mDrawerItems[1]));
items.add(new ListItem(mDrawerItems[2]));
items.add(new ListItem(mDrawerItems[3]));
items.add(new ListItem(mDrawerItems[4]));
items.add(new NavDrawerListHeader(""));
items.add(new ListItem(mDrawerItems[5]));
items.add(new ListItem(mDrawerItems[6]));
TextArrayAdapter adapter = new TextArrayAdapter(this, items);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
// set a custom shadow that overlays the main content when the drawer opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener
mDrawerList.setAdapter(adapter);
// mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mDrawerItems));
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
// ActionBarDrawerToggle ties together the the proper interactions
// between the sliding drawer and the action bar app icon
mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description for accessibility */
R.string.drawer_close) {
/* "close drawer" description for accessibility */
public void onDrawerClosed(View view) {
//getSupportActionBar().setTitle(mTitle);
}
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setTitle(mTitle);
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
// Enable ActionBar app icon to behave as action to toggle navigation drawer
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
if (savedInstanceState == null) {
selectItem(0);
}
setTitleNormal();
// Uncomment the following to enable listening on local port 8080:
/*
* try {
* HelloServer h = new HelloServer();
* } catch (IOException e) {
* e.printStackTrace();
* }
*/
}
Aggregations