android.support.v7.widget.Toolbar Java Examples
The following examples show how to use
android.support.v7.widget.Toolbar.
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: CreateActivity.java From materialup with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create); ButterKnife.bind(this); 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) { fabClick(view); } }); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
Example #2
Source File: SettingsActivity.java From sharelock-android with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); Toolbar toolbar = (Toolbar) findViewById(R.id.sharelock_toolbar); setSupportActionBar(toolbar); setTitle(null); endpointEditText = (TextView) findViewById(R.id.settings_endpoint_url); final SharedPreferences preferences = getSharedPreferences(getPackageName(), MODE_PRIVATE); endpointEditText.setText(preferences.getString(LinkAPIClient.SHARELOCK_ENDPOINT_KEY, LinkAPIClient.DEFAULT_URL)); Button resetButton = (Button) findViewById(R.id.settings_default_button); resetButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { endpointEditText.setText(LinkAPIClient.DEFAULT_URL); } }); }
Example #3
Source File: Playground.java From SuperToasts with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_playground); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); final Button button = (Button) findViewById(R.id.random); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getRandomSuperToast().show(); } }); SuperActivityToast.onRestoreState(this, savedInstanceState, ListenerUtils.newInstance() .putListener("good_tag_name", onButtonClickListener)); }
Example #4
Source File: SwipeableCard.java From SwipeableCard with Apache License 2.0 | 6 votes |
/** * Animation Card for up animation, please do not modify this. * @param card card view instance * @param toolbar toolbar instance */ @Override public void animationCardUp(@NotNull final CardView card, @NotNull final Toolbar toolbar, final long duration){ new CountDownTimer(1, 1) { public void onTick(long millisUntilFinished) { } public void onFinish() { card.animate() .translationY(height - (card.getHeight() + toolbar.getHeight())) .setDuration(duration).start(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { fab.animate() .translationY((height - (card.getHeight() + toolbar.getHeight())) + card.getHeight() - (fab.getHeight() - fab.getHeight() / 4)) .setDuration(duration).start(); }else { fab.animate() .translationY((height - (card.getHeight() + toolbar.getHeight())) + card.getHeight() - (fab.getHeight() - fab.getHeight() / 3)) .setDuration(duration).start(); } } }.start(); }
Example #5
Source File: MainActivity.java From XModulable with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity_main); Toolbar toolbar = findViewById(R.id.main_toolbar); setSupportActionBar(toolbar); getSupportActionBar().setHomeButtonEnabled(false); // 设置导航按钮无效 getSupportActionBar().setDisplayHomeAsUpEnabled(false); // 不显示导航按钮 getSupportActionBar().setDisplayShowTitleEnabled(true); // 显示标题 TabLayout tabLayout = findViewById(R.id.main_tab_layout); ViewPager viewPager = findViewById(R.id.main_pager); LinkedHashMap<String, Fragment> fragments = new LinkedHashMap<>(3); fragments.put("main", new MainFragment()); if (liveModule != null) { fragments.put("live", liveModule.getLiveService().createLiveEntranceFragment()); } if (imModule != null) { fragments.put("im", imModule.getIMService().createIMEntranceFragment()); } viewPager.setAdapter(new MainPagerAdapter(getSupportFragmentManager(), fragments)); tabLayout.setupWithViewPager(viewPager); }
Example #6
Source File: ChatGroupsListActivity.java From chat21-android-sdk with GNU Affero General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_chat_groups_list); contactsListFragment = new ChatGroupsListFragment(); contactsListFragment.setOnChatGroupClickListener(this); // #### BEGIN TOOLBAR #### Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // #### END TOOLBAR #### // #### BEGIN CONTAINER #### getSupportFragmentManager() .beginTransaction() .replace(R.id.container, contactsListFragment) .commit(); // #### BEGIN CONTAINER #### }
Example #7
Source File: SettingsActivity.java From video-transcoder with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.settings_layout); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if(actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } // Display the fragment as the main content. getFragmentManager().beginTransaction() .replace(R.id.fragment_container, new SettingsFragment()) .commit(); }
Example #8
Source File: MainActivity.java From FirebaseMessagingApp with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); mLogoutPresenter = new LogoutPresenter(this); viewPager = (ViewPager) findViewById(R.id.viewpager); setupViewPager(viewPager); tabLayout = (TabLayout) findViewById(R.id.tabs); tabLayout.setupWithViewPager(viewPager); setupTabIcons(); }
Example #9
Source File: ToolbarContentTintHelper.java From APlayer with GNU General Public License v3.0 | 6 votes |
@Nullable public static Toolbar getSupportActionBarView(@Nullable ActionBar ab) { if (ab == null || !(ab instanceof WindowDecorActionBar)) { return null; } try { WindowDecorActionBar decorAb = (WindowDecorActionBar) ab; Field field = WindowDecorActionBar.class.getDeclaredField("mDecorToolbar"); field.setAccessible(true); ToolbarWidgetWrapper wrapper = (ToolbarWidgetWrapper) field.get(decorAb); field = ToolbarWidgetWrapper.class.getDeclaredField("mToolbar"); field.setAccessible(true); return (Toolbar) field.get(wrapper); } catch (Throwable t) { throw new RuntimeException( "Failed to retrieve Toolbar from AppCompat support ActionBar: " + t.getMessage(), t); } }
Example #10
Source File: AboutActivity.java From MLManager with GNU General Public License v3.0 | 6 votes |
private void setInitialConfiguration() { Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setTitle(R.string.action_about); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { onBackPressed(); } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getWindow().setStatusBarColor(UtilsUI.darker(appPreferences.getPrimaryColorPref(), 0.8)); toolbar.setBackgroundColor(appPreferences.getPrimaryColorPref()); if (!appPreferences.getNavigationBlackPref()) { getWindow().setNavigationBarColor(appPreferences.getPrimaryColorPref()); } } }
Example #11
Source File: AtUserActivity.java From iBeebo with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.at_user_activity_layout); Toolbar mAtUserToolBar = (Toolbar) findViewById(R.id.atUserToolbar); String token = getIntent().getStringExtra(TOKEN_HACK); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .replace(R.id.at_content_frame, new AtUserFragment(token, mAtUserToolBar)).commit(); } disPlayHomeAsUp(mAtUserToolBar); }
Example #12
Source File: StaticShortcutActivity.java From journaldev with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_static_shortcut); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); TextView textView = findViewById(R.id.tvTitle); if (getIntent() != null && getIntent().getStringExtra("key") != null) { String bundleString = getIntent().getStringExtra("key"); textView.setText(bundleString); } FloatingActionButton fab = 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(); } }); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
Example #13
Source File: DemoCustomView02Activity.java From RecyclerTabLayout with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_demo_custom_view02); Demo demo = Demo.valueOf(getIntent().getStringExtra(KEY_DEMO)); Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle(demo.titleResId); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); DemoImagePagerAdapter adapter = new DemoImagePagerAdapter(); adapter.addAll(DemoData.loadImageResourceList()); ViewPager viewPager = findViewById(R.id.view_pager); viewPager.setAdapter(adapter); RecyclerTabLayout recyclerTabLayout = findViewById(R.id.recycler_tab_layout); recyclerTabLayout.setUpWithAdapter(new DemoCustomView02Adapter(viewPager)); recyclerTabLayout.setPositionThreshold(0.5f); }
Example #14
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); mListView = (ListView) findViewById(R.id.list); mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, new ArrayList<String>()); mAdapter.add("Movie 1"); mAdapter.add("Movie 2"); mAdapter.add("Movie 3"); mAdapter.add("Movie 4"); mAdapter.add("Movie 5"); mAdapter.add("Movie 6"); mAdapter.add("Movie 7"); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(this); CastContext.getSharedInstance(this).addCastStateListener(this); CastContext.getSharedInstance(this).addAppVisibilityListener(this); CastContext.getSharedInstance(this).getSessionManager().addSessionManagerListener(this); }
Example #15
Source File: CollapsingToolbarLayoutActivity.java From Android-skin-support with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_collapsing_toolbar_layout); mIvPlaceholder = (ImageView) findViewById(R.id.main_iv_placeholder); mLlTitleContainer = (LinearLayout) findViewById(R.id.main_ll_title_container); mFlTitleContainer = (FrameLayout) findViewById(R.id.main_fl_title); mAblAppBar = (AppBarLayout) findViewById(R.id.main_abl_app_bar); mTvToolbarTitle = (TextView) findViewById(R.id.main_tv_toolbar_title); mTbToolbar = (Toolbar) findViewById(R.id.main_tb_toolbar); mTbToolbar.setTitle(""); // AppBar的监听 mAblAppBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { int maxScroll = appBarLayout.getTotalScrollRange(); float percentage = (float) Math.abs(verticalOffset) / (float) maxScroll; handleAlphaOnTitle(percentage); handleToolbarTitleVisibility(percentage); } }); findViewById(R.id.small_photo).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { startActivity(new Intent(CollapsingToolbarLayoutActivity.this, SettingsActivity.class)); } }); initParallaxValues(); // 自动滑动效果 }
Example #16
Source File: MainActivity.java From AndResGuard with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics(), new CrashlyticsNdk()); setContentView(R.layout.activity_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, "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); }
Example #17
Source File: MainActivity.java From AndroidBarUtils with Apache License 2.0 | 5 votes |
private void initToolBar() { toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); //设置填充间距 AndroidBarUtils.setBarPaddingTop(this, toolbar); //设置ToolBar 颜色 setToolBarBackgroundColor(alpha, red, green, blue); }
Example #18
Source File: IconTabActivity.java From MaterialTabs with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_icons); res = this.getResources(); // init toolbar (old action bar) Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar); toolbar.setTitleTextColor(Color.WHITE); this.setSupportActionBar(toolbar); tabHost = (MaterialTabHost) this.findViewById(R.id.tabHost); pager = (ViewPager) this.findViewById(R.id.pager); // init view pager pagerAdapter = new ViewPagerAdapter(getSupportFragmentManager()); pager.setAdapter(pagerAdapter); pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // when user do a swipe the selected tab change tabHost.setSelectedNavigationItem(position); } }); // insert all tabs from pagerAdapter data for (int i = 0; i < pagerAdapter.getCount(); i++) { tabHost.addTab( tabHost.newTab() .setIcon(getIcon(i)) .setTabListener(this) ); } }
Example #19
Source File: SettingsActivity.java From 920-text-editor-v2 with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.setting_activity); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Display the fragment as the main content. getFragmentManager().beginTransaction() .replace(R.id.content, new SettingsFragment()) .commit(); }
Example #20
Source File: FriendFacebookActivity.java From Expert-Android-Programming with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_friends_search); toolbar = (Toolbar) findViewById(R.id.toolbar1); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle("Find friends on Facebook"); toolbar.setTitleTextColor(ContextCompat.getColor(context, R.color.white)); recyclerView = (RecyclerView) findViewById(R.id.recyclerView); allList = new ArrayList<>(); allAdapter = new FriendAdapter(context, allList); /* allAdapter.setClickListener(new FriendAdapter.ClickListener() { @Override public void onItemClickListener(View v, int pos) { } @Override public void onFriendListener(int pos, boolean isFollowing) { } });*/ recyclerView.setLayoutManager(new LinearLayoutManager(context)); recyclerView.setNestedScrollingEnabled(false); recyclerView.setAdapter(allAdapter); setList(); }
Example #21
Source File: BaseActivity.java From Dashboard with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutResource()); prefs = getSharedPreferences("com.antonioleiva.materialeverywhere", MODE_PRIVATE); toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); } }
Example #22
Source File: SponsorActivity.java From Hillffair17 with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sponsor); // String BASE_URL="https://s3.ap-south-1.amazonaws.com/hillffair2016/images/"; String BASE_URL="https://github.com/"; rvSponsor = findViewById(R.id.rvSponsor); progressBar = findViewById(R.id.sponsor_progressbar); sponsorItems = new ArrayList<>(); // sponsorItems.add(new SponsorItem("SkyCandle.in",BASE_URL+"appteam-nith.png")); // sponsorItems.add(new SponsorItem("Board Of School Education, H.P.",BASE_URL+"appteam-nith.png")); // sponsorItems.add(new SponsorItem("Tata Shaktee",BASE_URL+"appteam-nith.png")); // sponsorItems.add(new SponsorItem("Cad Desk",BASE_URL+"appteam-nith.png")); // // sponsorItems.add(new SponsorItem("",BASE_URL+"appteam-nith4.png")); // sponsorItems.add(new SponsorItem("HPSEDC",BASE_URL+"appteam-nith.png")); // sponsorItems.add(new SponsorItem("Ratan Jewellers",BASE_URL+"appteam-nith.png")); // sponsorItems.add(new SponsorItem("Chankya The Guru",BASE_URL+"appteam-nith.png")); // sponsorItems.add(new SponsorItem("L'OREAL",BASE_URL+"appteam-nith.png")); // // sponsorAdapter = new SponsorAdapter(sponsorItems,SponsorActivity.this); rvSponsor.setAdapter(sponsorAdapter); tbSponsor = (Toolbar)findViewById(R.id.tbSponsor); tbSponsor.setTitle("Our Sponsors"); setSupportActionBar(tbSponsor); getSupportActionBar().setDisplayHomeAsUpEnabled(true); progressBar.setVisibility(View.VISIBLE); LinearLayoutManager lvmanager = new LinearLayoutManager(this); lvmanager.setOrientation(LinearLayoutManager.VERTICAL); rvSponsor.setLayoutManager(lvmanager); getSponsors(); }
Example #23
Source File: PandroidDrawerActivity.java From pandroid with Apache License 2.0 | 5 votes |
@Override public void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); drawer = (DrawerLayout) findViewById(getDrawerId()); Toolbar toolbar = (Toolbar) findViewById(getToolbarId()); mDrawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.drawer_open, R.string.drawer_close); setSupportActionBar(toolbar); drawer.addDrawerListener(mDrawerToggle); mDrawerToggle.syncState(); }
Example #24
Source File: MainActivity.java From Gank with Apache License 2.0 | 5 votes |
private void initViews() { mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); View headerView= navigationView.inflateHeaderView(R.layout.nav_header_main); navigationView.setNavigationItemSelectedListener(this); headerView.findViewById(R.id.head_img).setOnClickListener(this); headerView.findViewById(R.id.head_web).setOnClickListener(this); headerView.findViewById(R.id.head_name).setOnClickListener(this); mRefreshLayout = (RefreshLayout) findViewById(R.id.id_swipe_ly); mRefreshLayout.setOnRefreshListener(this); mRefreshLayout.setOnLoadListener(this); mAdapter = new GankCommonAdapter(MainActivity.this,null); mListView = (ListView) findViewById(R.id.id_listview); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(this); mListView.setOnScrollListener(new PauseOnScrollListener(ImageLoader.getInstance(), true, false)); }
Example #25
Source File: BaseActivity.java From Learning-Resources with MIT License | 5 votes |
/** * Center the Toolbar Title. * * @param toolbar */ protected void centerTitle(Toolbar toolbar) { final CharSequence originalTitle = toolbar.getTitle(); TextView mTitle = toolbar.findViewById(R.id.toolbarTitle); mTitle.setText(originalTitle); getSupportActionBar().setDisplayShowTitleEnabled(false); toolbar.setTitle(""); }
Example #26
Source File: NewActivity.java From StreamHub-Android-SDK with MIT License | 5 votes |
private void setListenersToViewsAndSetConfig() { toolbar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowTitleEnabled(false); //Activity Name TextView activityName = (TextView) findViewById(R.id.activityTitle); if (purpose.equals(Constant.NEW_COMMENT)) { commentEt.setHint("Write your comment here...");//setting hint to Edittext activityName.setText("New Comment"); } else if (purpose.equals(Constant.NEW_REPLY)) { commentEt.setHint("Write your Reply here...");//setting hint to Edittext activityName.setText("Reply"); attachImageLL.setVisibility(View.VISIBLE);//Hide Image Selection option } else if (purpose.equals(Constant.EDIT)) { activityName.setText("Edit"); attachImageLL.setVisibility(View.GONE);//Hide Image Selection option } //Activity Icon ImageView homeIcon = (ImageView) findViewById(R.id.activityIcon); homeIcon.setBackgroundResource(R.drawable.close_b); LinearLayout activityIconLL = (LinearLayout) findViewById(R.id.activityIconLL); activityIconLL.setOnClickListener(homeIconListener); //Action TextView actionTv = (TextView) findViewById(R.id.actionTv); actionTv.setText("POST"); LinearLayout actionLL = (LinearLayout) findViewById(R.id.actionLL); actionLL.setVisibility(View.VISIBLE); actionLL.setOnClickListener(actionTvListener); }
Example #27
Source File: ManageAccountActivity.java From wmn-safety with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_account); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); setTitle("Update Account"); mNameInputEditText = findViewById(R.id.account_update_full_name); mEmailInputEditText = findViewById(R.id.account_update_email); mPhoneInputEditText = findViewById(R.id.account_update_phone); mFirebaseAuth = FirebaseAuth.getInstance(); mFirebaseUser = mFirebaseAuth.getCurrentUser(); mFirebaseDatabase = FirebaseDatabase.getInstance(); mDatabaseReference = mFirebaseDatabase.getReference().child("users"); mDatabaseReference.child(mFirebaseUser.getUid()).addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { UserData userData = dataSnapshot.getValue(UserData.class); if(userData != null) { mNameInputEditText.setText(userData.getName()); mEmailInputEditText.setText(userData.getEmail()); mPhoneInputEditText.setText(userData.getNumber()); } } @Override public void onCancelled(DatabaseError databaseError) { } }); }
Example #28
Source File: MainActivity.java From scroball with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); application = (ScroballApplication) getApplication(); application.startListenerService(); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = findViewById(R.id.container); mViewPager.setAdapter(mSectionsPagerAdapter); TabLayout tabLayout = findViewById(R.id.tabs); tabLayout.setupWithViewPager(mViewPager); // Initial tab may have been specified in the intent. int initialTab = getIntent().getIntExtra(EXTRA_INITIAL_TAB, TAB_NOW_PLAYING); mViewPager.setCurrentItem(initialTab); this.adsRemoved = application.getSharedPreferences().getBoolean(REMOVE_ADS_SKU, false); adView = findViewById(R.id.adView); if (this.adsRemoved) { RelativeLayout parent = (RelativeLayout) adView.getParent(); if (parent != null) { parent.removeView(adView); } } else { AdRequest adRequest = new AdRequest.Builder().addTestDevice("86193DC9EBC8E1C3873178900C9FCCFC").build(); adView.loadAd(adRequest); } }
Example #29
Source File: MainActivity.java From RefreshLoadMoreRecyclerView with MIT License | 5 votes |
/** * 初始化视图 */ private void initViews() { mToolBar = (Toolbar) findViewById(R.id.id_toolbar); if (mToolBar != null) setSupportActionBar(mToolBar); mRecyclerView = (HarvestRecyclerView) findViewById(R.id.id_harvest_recyclerview); manager = new LinearLayoutManager(this); mRecyclerView.setHasFixedSize(true); mRecyclerView.setLayoutManager(manager); mRecyclerView.setEmptyView(getResources().getDrawable(R.drawable.ic_results_empty), "No data Here.", new View.OnClickListener() { @Override public void onClick(View v) { adapter.data.add("onRefresh" + refreshNum++); adapter.notifyDataSetChanged(); } }); onRefreshListener = new HarvestRecyclerView.OnRefreshListener() { @Override public void onRefresh() { if (refreshNum >= 8) { adapter.data.clear(); } else adapter.data.add(0, "onRefresh" + refreshNum++); adapter.notifyDataSetChanged(); } }; onLoadMoreListener = new HarvestRecyclerView.OnLoadMoreListener() { @Override public void onLoadMore() { if (loadMoreNum >= 8) { mRecyclerView.setLoadMoreEnabled(false, null); } else adapter.data.add("onLoadMore" + loadMoreNum++); adapter.notifyDataSetChanged(); } }; }
Example #30
Source File: MainActivity.java From MaterialDesignColors with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle( this, drawerLayout, R.string.navigation_drawer_open, R.string.navigation_drawer_close ); mDrawerToggle.setDrawerIndicatorEnabled(true); drawerLayout.addDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.replace(R.id.fragment_container, new ColorPaletteFragment()); transaction.commit(); }