@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); DataBindingUtil.setContentView(this, R.layout.activity_main); NavigationView navigation = (NavigationView) findViewById(R.id.main_nav); navigation.setNavigationItemSelectedListener(this); drawer = (DrawerLayout) findViewById(R.id.main_drawer); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, 0, 0); drawer.setDrawerListener(toggle); toggle.syncState(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); chapter = new ChapterFragment(); forum = new ForumFragment(); game = new GameFragment(); transaction .add(R.id.main_container, chapter) .add(R.id.main_container, forum) .add(R.id.main_container, game) .detach(forum) .detach(game) .detach(chapter) .attach(chapter) .commit(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mCoordinator = (CoordinatorLayout) findViewById(R.id.root_coordinator); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mToolbar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(mToolbar); navigationView = (NavigationView) findViewById(R.id.navigation_drawer); navigationView.setItemIconTintList(null); navigationView.setNavigationItemSelectedListener(this); mDrawerToggle = new ActionBarDrawerToggle( this, mDrawerLayout, mToolbar, R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerToggle.syncState(); mTabLayout = (TabLayout) findViewById(R.id.tab_layout); mAdapter = new TabPagerAdapter(this, getSupportFragmentManager()); mPager = (ViewPager) findViewById(R.id.view_pager); mPager.setAdapter(mAdapter); // Notice how the Tab Layout links with the Pager Adapter mTabLayout.setTabsFromPagerAdapter(mAdapter); // Notice how The Tab Layout adn View Pager object are linked mTabLayout.setupWithViewPager(mPager); mPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout)); if (getIntent() != null) { mPager.setCurrentItem(getIntent().getIntExtra("tab", 0)); } fragmentManager = getSupportFragmentManager(); }
@Override protected void onCreate(Bundle savedInstanceState) { // oncreate set up super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); myDb = new DatabaseHelper(this); // db helper class created. Courseid = myDb .newCourseDBInstert(); // This will add an insert and return the id for the user in this // session Log.i("Main long", Courseid + ""); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); FragmentManager fm = getFragmentManager(); fm.beginTransaction().replace(R.id.content_frame, new ViewScores()).commit(); setTitle("Scores"); }
private void setupDrawer() { View headerLayout = mNavigationView.getHeaderView(0); TextView userName = (TextView) headerLayout.findViewById(R.id.user_name_txt); TextView userEmail = (TextView) headerLayout.findViewById(R.id.user_email_txt); userName.setText(mDataManager.getPreferencesManager().getUserName()); userEmail.setText(mDataManager.getPreferencesManager().getEmail()); setRoundedAvatar(); mNavigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.team_menu: mNavigationDrawer.closeDrawer(GravityCompat.START); break; case R.id.user_profile_menu: Intent profileIntent = new Intent(UserListActivity.this, MainActivity.class); startActivity(profileIntent); mNavigationDrawer.closeDrawer(GravityCompat.START); break; case R.id.exit_menu: mDataManager.getPreferencesManager().saveAuthToken(""); Intent exitIntent = new Intent(UserListActivity.this, AuthActivity.class); startActivity(exitIntent); } return true; } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_page); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } }); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); }
private void configViews() { // 设置显示Toolbar setSupportActionBar(mToolbar); // 设置Drawerlayout开关指示器,即Toolbar最左边的那个icon ActionBarDrawerToggle mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open, R.string.close); mActionBarDrawerToggle.syncState(); mDrawerLayout.setDrawerListener(mActionBarDrawerToggle); // 给NavigationView填充顶部区域,也可在xml中使用app:headerLayout="@layout/header_nav"来设置 mNavigationView.inflateHeaderView(R.layout.view_nav_header); // 给NavigationView填充Menu菜单,也可在xml中使用app:menu="@menu/menu_nav"来设置 mNavigationView.inflateMenu(R.menu.menu_nav); // 自己写的方法,设置NavigationView中menu的item被选中后要执行的操作 onNavgationViewMenuItemSelected(mNavigationView); // 初始化ViewPager的适配器,并设置给它 pageAdapter = new CardPageAdapter(getSupportFragmentManager(), mTitles); mViewPager.setAdapter(pageAdapter); // 设置ViewPager最大缓存的页面个数 mViewPager.setOffscreenPageLimit(5); // 给ViewPager添加页面动态监听器(为了让Toolbar中的Title可以变化相应的Tab的标题) mViewPager.addOnPageChangeListener(this); mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE); // 将TabLayout和ViewPager进行关联,让两者联动起来 mTabLayout.setupWithViewPager(mViewPager); // 设置Tablayout的Tab显示ViewPager的适配器中的getPageTitle函数获取到的标题 mTabLayout.setTabsFromPagerAdapter(pageAdapter); // 设置FloatingActionButton的点击事件 mFloatingActionButton.setOnClickListener(this); }
private void initNavigation() { drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); drawerToggle = new ActionBarDrawerToggle( MainActivity.this, drawerLayout, R.string.hello_world, R.string.hello_world); drawerLayout.setDrawerListener(drawerToggle); NavigationView navigationView = (NavigationView) findViewById(R.id.navigation); navigationView.setNavigationItemSelectedListener(new MyOnNavItemListener()); navMenu = navigationView.getMenu(); navMenu.getItem(0).setChecked(true); sharedPreferences = getSharedPreferences(SpConfig.Name, Context.MODE_PRIVATE); String icon = sharedPreferences.getString(SpConfig.PERSON_ICON, ""); TextView navName = (TextView) navigationView.findViewById(R.id.nav_header_name); String name = sharedPreferences.getString(SpConfig.PERSON_NAME, ""); navName.setText(name); ImageView navIcon = (ImageView) navigationView.findViewById(R.id.nav_header_icon); ImageHelper imageHelper = ImageHelper.getInstance(getApplicationContext()); imageHelper.loadCircleImage(navIcon, icon, 120); String portalName = sharedPreferences.getString(SpConfig.P_NAME, ""); String portalPw = sharedPreferences.getString(SpConfig.P_PW, ""); portalHelper = new PortalHelper(getApplicationContext()); if (StringUtil.isNull(portalName) || StringUtil.isNull(portalPw)) { navMenu.getItem(2).setVisible(false); } else { portalHelper.info(new PortalInfo()); } }
private void setupNavigationView() { NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view); navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.nav_profile: fragmentManager.beginTransaction().replace(R.id.frame_layout, fragment1).commit(); break; case R.id.nav_settings: fragmentManager.beginTransaction().replace(R.id.frame_layout, fragment2).commit(); break; case R.id.nav_social: fragmentManager.beginTransaction().replace(R.id.frame_layout, fragment3).commit(); break; default: break; } drawerLayout.closeDrawers(); return true; } }); navigationView.setItemIconTintList(ContextCompat.getColorStateList(this, R.color.my_icon_tint)); navigationView.setItemTextColor(ContextCompat.getColorStateList(this, R.color.my_icon_tint)); navigationView.setItemTextAppearance(R.style.myNavigationText); }
@Override protected void initView() { toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } }); drawer = (DrawerLayout) findViewById(R.id.drawer_layout); toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); View headerView = navigationView.getHeaderView(0); avatar = (ImageView) headerView.findViewById(R.id.imageView); avatar.setOnClickListener(this); switch2News(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // ROTAZIONE SCHERMO BLOCCATA this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); viewPager = (ViewPager) findViewById(R.id.viewpagerHome); setupViewPager(viewPager); tabLayout = (TabLayout) findViewById(R.id.tabsHome); tabLayout.setupWithViewPager(viewPager); setTitle("Home"); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mUserPreference = new UserPreference(MainActivity.this); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); View headerView = navigationView.getHeaderView(0); TextView txtUsername = (TextView) headerView.findViewById(R.id.txt_username); TextView txtEmail = (TextView) headerView.findViewById(R.id.txt_email); txtUsername.setText(mUserPreference.getName()); txtEmail.setText(mUserPreference.getEmail()); if (mCurrentLocationFragment == null) { mCurrentLocationFragment = new CurrentLocationFragment(); } setUpFragment(mCurrentLocationFragment, CurrentLocationFragment.class.getSimpleName()); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppController.getController().getBus().register(this); manager = new GridLayoutManager(this, getResources().getInteger(R.integer.num_row)); recycler.setItemAnimator(new DefaultItemAnimator()); recycler.setHasFixedSize(true); recycler.setLayoutManager(manager); mDrawerLayout.setStatusBarBackgroundColor( AppHelper.getPrimaryDarkColor(AppHelper.getPrimaryColor(this))); navigationView.setItemIconTintList(ColorStateList.valueOf(AppHelper.getAccentColor(this))); if (AppHelper.isDarkTheme(this)) { navigationView.setItemTextColor(ColorStateList.valueOf(AppHelper.getAccentColor(this))); } adapter = new AppsAdapter(this, new ArrayList<AppsModel>()); recycler.setAdapter(adapter); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (navigationView != null) { setupDrawerContent(navigationView); } getLoaderManager().restartLoader(0, null, this); productsList.addAll(Arrays.asList(getResources().getStringArray(R.array.in_app_billing))); mHelper = new IabHelper(this, getString(R.string.base64)); mHelper.startSetup(mPurchaseFinishedListener); showWhatsNew(); countBackup(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); ScreenFragment startFragment = new ScreenFragment(); fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.view_fragment, startFragment).commit(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); }
protected NavigationView setupDrawer(int drawerLayoutIdToLoad) { navigationView = (NavigationView) findViewById(R.id.navigation_view); _mDrawerLayout = (DrawerLayout) findViewById(drawerLayoutIdToLoad); // In Android support 23.2.1, there is a bug where you can't inflate the menu in XML, must be // done manually navigationView.inflateMenu(R.menu.drawer_menu_items); navigationView.inflateHeaderView(R.layout.drawer_header); navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { // This method will trigger on item Click of navigation menu @Override public boolean onNavigationItemSelected(MenuItem menuItem) { return selectDrawerItem(menuItem); } }); _mDrawerToggle = new ActionBarDrawerToggle( this, // Host Activity _mDrawerLayout, // DrawerLayout object R.string.navigation_drawer_open, // Description for accessibility R.string.navigation_drawer_close // Description for accessibility ); _mDrawerLayout.addDrawerListener(_mDrawerToggle); return navigationView; }
private void setUpNavView() { if (navigationDrawer != null) { navigationView = (NavigationView) findViewById(R.id.navigation_view); TextView name = (TextView) navigationView.getHeaderView(0).findViewById(R.id.account_name); name.setText(getPref(App.PREF_USER_NAME)); TextView email = (TextView) navigationView.getHeaderView(0).findViewById(R.id.account_email); email.setText(getPref(App.PREF_USER_EMAIL)); navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); switch (menuItem.getItemId()) { case R.id.navigation_item_1: mCurrentSelectedPosition = 0; navigationDrawer.closeDrawers(); return true; case R.id.navigation_item_2: mCurrentSelectedPosition = 1; navigationDrawer.closeDrawers(); return true; default: return true; } } }); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_start); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); this.setTitle(R.string.title_activity_start); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); checkSD(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pengamat); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); mController = new ControllerPengamat(PengamatActivity.this); // untuk swipeToRefresh configViews(); // mController.startFetching(); // rv2.setHasFixedSize(true); // initializeData(); // initializeAdapter(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // FragmentTransaction tx = getSupportFragmentManager().beginTransaction(); // tx.replace(R.id.container, new MapsFragment()); // tx.commit(); if (AppGlobals.isVirgin()) { Intent i = new Intent(MainActivity.this, LoginActivity.class); startActivity(i); } setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); }
/** * Initializes the activity and the view of the main page * * @param savedInstanceState */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); navHeaderLayout = navigationView.getHeaderView(0); // ATTENTION: This was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); }
private void findUI() { devDialog = new AlertDialog.Builder(ForecastActivity.this, R.style.AppCompatAlertDialogStyle); devDialog.setTitle("Печеньку?"); devDialog.setMessage("К сожалению раздел находится в разработке..."); devDialog.setPositiveButton( "ОК", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }); toolbar = (Toolbar) findViewById(R.id.toolbar); drawerLayout = (DrawerLayoutWithViewPager) findViewById(R.id.drawer_layout); navigationView = (NavigationView) findViewById(R.id.nav_view); b_cities = navigationView.getHeaderView(0).findViewById(R.id.b_cities); pagerMaterial = (ViewPager) navigationView.getHeaderView(0).findViewById(R.id.pager_material); pagerCity = (ViewPager) navigationView.getHeaderView(0).findViewById(R.id.pager_city); topbar = (LinearLayout) drawerLayout.findViewById(R.id.topbar); summary_box = (LinearLayout) drawerLayout.findViewById(R.id.summary_box); summary_city = (TextView) drawerLayout.findViewById(R.id.city); summary_daily = (TextView) drawerLayout.findViewById(R.id.summary); // summary_hourly = (TextView) drawerLayout.findViewById(R.id.summary_hourly); summary_city.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fadein)); summary_daily.startAnimation(AnimationUtils.loadAnimation(this, R.anim.fadein)); scroll = (SwipeRefreshLayout) drawerLayout.findViewById(R.id.scroll); scroll.setProgressViewOffset(false, -100, 100); }
private void initNavigationView() { drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawerLayout, toolbar, R.string.view_navigation_open, R.string.view_navigation_close); drawerLayout.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.navigation); navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { drawerLayout.closeDrawers(); switch (menuItem.getItemId()) { case R.id.actionNotificationItem: showNotificationTab(); } return true; } }); }
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (mDrawerLayout != null) { // Load saved navigation state if present if (null == savedInstanceState) { mNavItemId = R.id.drawer_contact; } else { mNavItemId = savedInstanceState.getInt(NAV_ITEM_ID); } // Listen for navigation events NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view); navigationView.setNavigationItemSelectedListener(this); // Select the correct nav menu item navigationView.getMenu().findItem(mNavItemId).setChecked(true); // Initialize the Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setupToolbar(toolbar); // Load the selected fragment navigate(mNavItemId); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_people); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); // TODO: for debug purposes. Delete when finished final ArrayList<User> sampleUsersList = User.getSampleUsersList(PeopleActivity.this); ArrayList<User> userList = new ArrayList<>(); Cursor cursor = new UserSqlOperations(this) .queryAll(null, UserContract.Columns.USERNAME, SqlOperations.SortOrder.ASC); while (cursor.moveToNext()) { Log.v(TAG, "Next cursor position"); User user = User.makeUser(cursor); userList.add(user); if (user != null) Log.v(TAG, String.format("User created: %s", user.toString())); } listView = (ListView) findViewById(R.id.people_list_view); listAdapter = new PeopleListAdapter(this, userList); listAdapter.notifyDataSetChanged(); if (listView != null) listView.setAdapter(listAdapter); // set FAB final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_people); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { // TODO: implement adding new user Toast.makeText( PeopleActivity.this, "Sorry, this was my next thing to do. It is actually done on server side", Toast.LENGTH_SHORT) .show(); } }); // connect to FollowersService bindService(FollowersService.makeIntent(this), followerServiceConnection, BIND_AUTO_CREATE); }
public static void updateNavigationItemTint(NavigationView navigationView, int primaryColorRes) { Context context = navigationView.getContext(); int primaryColor = ContextCompat.getColor(context, primaryColorRes); navigationView.setItemIconTintList( createNavigationItemTintList(android.R.attr.textColorSecondary, primaryColor, context)); navigationView.setItemTextColor( createNavigationItemTintList(android.R.attr.textColorPrimary, primaryColor, context)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ButterKnife.bind(this); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); menu = navigationView.getMenu(); // Load menu // deleteDatabase("sub_reddit-db"); DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "sub_reddit-db", null); SQLiteDatabase db = helper.getWritableDatabase(); DaoMaster daoMaster = new DaoMaster(db); DaoSession daoSession = daoMaster.newSession(); SubRedditDao subRedditDao = daoSession.getSubRedditDao(); menuList = subRedditDao.loadAll(); if (menuList.size() == 0) { // init Log.i("MyTag", "Subreddit init - list was empty"); subRedditDao.insert(new SubReddit(null, "art", "art")); subRedditDao.insert(new SubReddit(null, "belgium", "belgium")); subRedditDao.insert(new SubReddit(null, "gifs", "gifs")); subRedditDao.insert(new SubReddit(null, "funny", "funny")); subRedditDao.insert(new SubReddit(null, "pics", "pics")); subRedditDao.insert(new SubReddit(null, "diy", "diy")); menuList = subRedditDao.loadAll(); } // Dynamicly load menu for (SubReddit item : menuList) { menu.add(R.id.menuSubreddit, menuList.indexOf(item), Menu.NONE, item.getTitle()); } // Load fragment Bundle bundle = new Bundle(); bundle.putLong("subRedditId", menuList.get(0).getId()); Fragment fragment = new SubRedditListFragment(); fragment.setArguments(bundle); getSupportFragmentManager() .beginTransaction() .add(R.id.frameLayoutMain, fragment) .addToBackStack(null) .commit(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } }); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); // bagian menu tabs viewPagerMain = (ViewPager) findViewById(R.id.viewpagerMain); setupViewPager(viewPagerMain); tabLayoutMain = (TabLayout) findViewById(R.id.tabsMain); tabLayoutMain.setupWithViewPager(viewPagerMain); setupTabIcons(); // bagian notifikasi GCMClientManager pushClientManager = new GCMClientManager(this, GCM_SENDER_ID); pushClientManager.registerIfNeeded( new GCMClientManager.RegistrationCompletedHandler() { @Override public void onSuccess(String registrationId, boolean isNewRegistration) { Log.d("Registration id", registrationId); // send this registrationId to your server } @Override public void onFailure(String ex) { super.onFailure(ex); } }); }
public int navigationDrawer() { for (int i = 0; i < mNavigationView.getMenu().size(); i++) { final MenuItem menuItem = mNavigationView.getMenu().getItem(i); if (menuItem.isChecked()) { return menuItem.getItemId(); } } return -1; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detalhes_celula); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); android.support.v7.app.ActionBar bar = getSupportActionBar(); bar.setTitle("Lista das Células"); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); celulaSelecionada = getIntent().getExtras().getParcelable("celulaSelecionada"); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(DetalhesCelula.this, MapsCelulas.class); Bundle parametros = new Bundle(); parametros.putString("filtroDia", "9"); parametros.putString("filtroTipo", "9"); intent.putExtras(parametros); intent.putExtra("celulaSelecionada", (Parcelable) celulaSelecionada); startActivity(intent); } }); TextView nome = (TextView) findViewById(R.id.textViewNome); nome.setText(celulaSelecionada.getNome()); TextView endereco = (TextView) findViewById(R.id.textViewEndereco); endereco.setText(celulaSelecionada.getEndereco()); TextView lider = (TextView) findViewById(R.id.textViewNomeLider); lider.setText(celulaSelecionada.getLiderNome()); TextView telefone = (TextView) findViewById(R.id.textViewTelefone); telefone.setText(celulaSelecionada.getTelefoneInformacao()); TextView dia = (TextView) findViewById(R.id.textViewDiaHora); dia.setText(celulaSelecionada.getDiaHora()); TextView tipo = (TextView) findViewById(R.id.textViewTipo); tipo.setText("Célula de " + celulaSelecionada.getTipo() + " - " + celulaSelecionada.getRede()); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map2); mapFragment.getMapAsync(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); IntentFilter filter = new IntentFilter(); filter.addAction(getString(R.string.intent_bl_stopped)); filter.addAction(getString(R.string.intent_action_bl_user_stopped)); filter.addAction(getString(R.string.intent_action_bl_user_changing)); LocalBroadcastManager.getInstance(this).registerReceiver(brdcstRcvr, filter); brcstRcvrBlAdapt = new BrcstBlAdaptChanged(); setContentView(R.layout.act_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, R.string.tst_fab, Snackbar.LENGTH_LONG) .setAction(R.string.cd_btn_filter, null) .show(); } }); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); rcycDevices = (RecyclerView) findViewById(R.id.my_recycler_view); rcycDevices.setHasFixedSize(true); rcycLayoutManager = new LinearLayoutManager(this); rcycDevices.setLayoutManager(rcycLayoutManager); rcycAdaptDevices = new AdaptScans(); rcycDevices.setAdapter(rcycAdaptDevices); if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show(); } if (savedInstanceState == null) { blAdapt = ((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_index); demenagement = (Button) findViewById(R.id.demenagement); menage = (Button) findViewById(R.id.menage); cours = (Button) findViewById(R.id.cour); autre = (Button) findViewById(R.id.autre); demenagement.setOnClickListener(this); menage.setOnClickListener(this); cours.setOnClickListener(this); autre.setOnClickListener(this); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); TextView wel = (TextView) findViewById(R.id.well); String user = ""; if (Login.loginuser != null) user = Login.loginuser; // wel.setText(Login.getLoginuser()); View view = getLayoutInflater().inflate(R.layout.nav_header_index, null); TextView log = (TextView) view.findViewById(R.id.TextView1); try { log.setText("Soyez le bienvenu " + user); } catch (Exception e) { } wel.setText("Soyez le bienvenu M " + user); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Index.this, RequestService.class); startActivity(intent); Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } }); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); }