Java Code Examples for android.support.v7.widget.Toolbar

The following are top voted examples for showing how to use android.support.v7.widget.Toolbar. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: MusicActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_music);

    Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setNavigationIcon(R.drawable.back);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    setupListView((ListView) findViewById(R.id.listView));
}
 
Example 2
Project: SmartRefreshLayout   File: ProfilePracticeActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_practice_profile);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    //状态栏透明和间距处理
    StatusBarUtil.immersive(this);
    StatusBarUtil.setPaddingSmart(this, toolbar);
    StatusBarUtil.setPaddingSmart(this, findViewById(R.id.profile));
    StatusBarUtil.setPaddingSmart(this, findViewById(R.id.blurview));
}
 
Example 3
Project: ConnectU   File: HorarioActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    setContentView(R.layout.activity_horario);
    //Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
        getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDarkGreen));
    }
    app = (App) getApplication();
    if (app.account == null && !app.loadUser()) //If account is null and cannot create user
        super.onDestroy();
    mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView = (RecyclerView) findViewById(R.id.horarioRecycler);
    emptyView = (LinearLayout) findViewById(R.id.horario_blank);
    recyclerView.setLayoutManager(mLayoutManager);

    initializePicker();
    getDateData(new Date());
}
 
Example 4
Project: changApp   File: ChangasFinalizadasActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_changas_finalizadas);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_cf);
    setupViewPager(viewPager);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerCF);
    // Adding menu icon to Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_cf));
    if (getSupportActionBar() != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        //getSupportActionBar().setHomeAsUpIndicator(indicator);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Mis changas finalizadas");
    }

}
 
Example 5
Project: Timeline   File: TimeLineActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_timeline);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    if(getSupportActionBar()!=null)
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mOrientation = (Orientation) getIntent().getSerializableExtra(MainActivity.EXTRA_ORIENTATION);
    mWithLinePadding = getIntent().getBooleanExtra(MainActivity.EXTRA_WITH_LINE_PADDING, false);

    setTitle(mOrientation == Orientation.HORIZONTAL ? getResources().getString(R.string.horizontal_timeline) : getResources().getString(R.string.vertical_timeline));

    mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    mRecyclerView.setLayoutManager(getLinearLayoutManager());
    mRecyclerView.setHasFixedSize(true);

    initView();
}
 
Example 6
Project: leoapp-sources   File: ChatActivity.java   View source code 6 votes vote down vote up
private void initToolbar() {
    Toolbar toolbar = findViewById(R.id.actionBarChat);
    toolbar.setTitleTextColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white));
    toolbar.setTitle(cname);
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_left);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);
    if (ctype != Chat.ChatType.PRIVATE && Utils.getController().getMessengerDatabase().userInChat(Utils.getUserID(), cid)) {
        toolbar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(getApplicationContext(), ChatEditActivity.class)
                        .putExtra("cid", cid)
                        .putExtra("cname", cname), 1);
            }
        });
    }
}
 
Example 7
Project: TimeTrix   File: SectionDetailsActivity.java   View source code 6 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        ActivitySectionDetailsBinding binding = DataBindingUtil.setContentView (this, R.layout.activity_section_details);
        mSectionIndex = getIntent ().getIntExtra (GlobalData.SECTION_INDEX, 1); //TODO do has extra
        Toolbar toolbar = (Toolbar) findViewById (R.id.toolbarSubDetail);
        setSupportActionBar (toolbar);
        android.support.v7.app.ActionBar actionBar = getSupportActionBar ();
        Button updateButton = (Button) findViewById (R.id.update);
        mSectionNameEditText = (EditText) findViewById (R.id.textViewSectionName);
        mSectionDescriptionEditText = (EditText) findViewById (R.id.textViewDescriptionName);
        updateButton.setOnClickListener (this);
//        Toast.makeText (SectionDetailsActivity.this, "file id ="+getIntent ().getLongExtra (GlobalData.SECTION_INDEX,-1), Toast.LENGTH_LONG).show ();
        mSubject = new SectionDetailsBinder (SectionDetailsActivity.this, mSectionIndex + 1);
        mSubject.setInputType ("none");
        binding.setSubject (mSubject);
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled (true);
        }
    }
 
Example 8
Project: SampleAppArch   File: AppArchNavigationDrawer.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  FloatingActionButton fab = findViewById(R.id.fab);
  fab.setOnClickListener(
      view -> Snackbar.make(view, "Want to set email ?", Snackbar.LENGTH_LONG)
          .setAction("Action", null).show());
  DrawerLayout drawer = findViewById(R.id.drawer_layout);
  ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
  drawer.addDrawerListener(toggle);
  toggle.syncState();
  NavigationView navigationView = findViewById(R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(this);
}
 
Example 9
Project: OpenHomeAnalysis   File: OhaEnergyUseBillFragment.java   View source code 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_energy_use_bill, container, false);
    this.radioButtonFromDate = (RadioButton) view.findViewById(R.id.radioButtonFromDate);
    this.radioButtonToDate = (RadioButton) view.findViewById(R.id.radioButtonToDate);
    this.editKwhCost = (EditText) view.findViewById(R.id.editKwhCost);
    this.datePicker = (DatePicker) view.findViewById(R.id.datePicker);
    this.toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    this.setTextRadioButtonDate(radioButtonFromDate, this.fromDate);
    this.setTextRadioButtonDate(radioButtonToDate, this.toDate);
    this.setCalendarView();
    this.editKwhCost.setText(OhaHelper.getEditable(this.kwhCost));
    this.radioButtonFromDate.setOnClickListener(this);
    this.radioButtonToDate.setOnClickListener(this);
    this.datePicker.setOnClickListener(this);
    //Remover o date_picker_header do datePicker se o mesmo existir
    View viewDayDatePicker = datePicker.findViewById(Resources.getSystem().getIdentifier("date_picker_header", "id", "android"));
    if (viewDayDatePicker != null) {
        viewDayDatePicker.setVisibility(View.GONE);
    }
    this.toolbar.inflateMenu(R.menu.fragment_energy_use_bill);
    this.toolbar.setOnMenuItemClickListener(this);
    return view;
}
 
Example 10
Project: MaterialOCR   File: UCropActivity.java   View source code 6 votes vote down vote up
/**
 * Configures and styles both status bar and toolbar.
 */
private void setupAppBar() {
    setStatusBarColor(mStatusBarColor);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);

    // Set all of the Toolbar coloring
    toolbar.setBackgroundColor(mToolbarColor);
    toolbar.setTitleTextColor(mToolbarWidgetColor);

    final TextView toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
    toolbarTitle.setTextColor(mToolbarWidgetColor);
    toolbarTitle.setText(mToolbarTitle);

    // Color buttons inside the Toolbar
    Drawable stateButtonDrawable = ContextCompat.getDrawable(this, mToolbarCancelDrawable).mutate();
    stateButtonDrawable.setColorFilter(mToolbarWidgetColor, PorterDuff.Mode.SRC_ATOP);
    toolbar.setNavigationIcon(stateButtonDrawable);

    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }
}
 
Example 11
Project: Tech-Jalsa   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);
    viewPager.setOffscreenPageLimit(ITEM_COUNT);

    tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Config.REGISTRATION_COMPLETE)) {
                FirebaseMessaging.getInstance().subscribeToTopic(Config.TOPIC_GLOBAL);
            } else if (intent.getAction().equals(Config.PUSH_NOTIFICATION)) {
                // new push notification is received
            }
        }
    };
}
 
Example 12
Project: ChromeLikeTabSwitcher   File: MainActivity.java   View source code 6 votes vote down vote up
/**
 * Returns the menu item, which shows the navigation icon of the tab switcher's toolbar.
 *
 * @return The menu item, which shows the navigation icon of the tab switcher's toolbar, as an
 * instance of the class {@link View} or null, if no navigation icon is shown
 */
@Nullable
private View getNavigationMenuItem() {
    Toolbar[] toolbars = tabSwitcher.getToolbars();

    if (toolbars != null) {
        Toolbar toolbar = toolbars.length > 1 ? toolbars[1] : toolbars[0];
        int size = toolbar.getChildCount();

        for (int i = 0; i < size; i++) {
            View child = toolbar.getChildAt(i);

            if (child instanceof ImageButton) {
                return child;
            }
        }
    }

    return null;
}
 
Example 13
Project: AndroidApp-Deploy   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    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, "Well done Paolo! Thanks too Dom and Mihchele", 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 14
Project: Hands-On-Android-UI-Development   File: NavigationMenuActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation_menu);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final 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();
        }
    });

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close
    );

    drawer.addDrawerListener(toggle);
    toggle.syncState();
    drawer.openDrawer(Gravity.START);
}
 
Example 15
Project: Tech-Jalsa   File: result.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_result);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    scoreLabel = (TextView) findViewById(R.id.scoreLabel);
    highScoreLabel = (TextView) findViewById(R.id.highScoreLabel);

    score = getIntent().getIntExtra(getString(R.string.score), 0);
    scoreLabel.setText(score + "");

    SharedPreferences settings = getSharedPreferences(getString(R.string.high_score), Context.MODE_PRIVATE);
    int highScore = settings.getInt(getString(R.string.high_score), 0);

    if (score > highScore) {
        highScoreLabel.setText(getString(R.string.high_score) + score);
        SharedPreferences.Editor editor = settings.edit();
        editor.putInt(getString(R.string.high_score), score);
        editor.commit();
    } else {
        highScoreLabel.setText(getString(R.string.high_score) + highScore);
    }
}
 
Example 16
Project: GoalsAndHabits   File: MyHabitsMapActivity.java   View source code 6 votes vote down vote up
/**
 * Called on activity start. Generates layout and button functionality.
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_habits_map);

    events = (ArrayList<HabitEvent>) getIntent().getSerializableExtra("event list");
    if (events==null || events.size()<1){finish();}


    Toolbar toolbar = (Toolbar) findViewById(R.id.actionbar);
    toolbar.setTitle("Map of My Habit History");
    toolbar.setNavigationIcon(R.drawable.ic_close_button);
    setSupportActionBar(toolbar);

    map = (MapView) findViewById(R.id.myHabitsMap);
    map.onCreate(savedInstanceState);
    map.getMapAsync(this);
}
 
Example 17
Project: SmartRefreshLayout   File: ViewPagerUsingFragment.java   View source code 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View root, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(root, savedInstanceState);

    final Toolbar toolbar = (Toolbar)root.findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });

    mRefreshLayout = (RefreshLayout) root.findViewById(refreshLayout);
    mRefreshLayout.setOnRefreshLoadmoreListener(this);
    mRefreshLayout.setRefreshHeader(new ClassicsHeader(getContext()));
    mRefreshLayout.setRefreshFooter(new ClassicsFooter(getContext()));

    mViewPager = (ViewPager) root.findViewById(R.id.viewPager);
    mTabLayout = (TabLayout) root.findViewById(R.id.tableLayout);

    mViewPager.setAdapter(mAdapter = new SmartPagerAdapter(Item.values()));
    mTabLayout.setupWithViewPager(mViewPager, true);
}
 
Example 18
Project: changApp   File: ChangasPorCategoriaActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_changas_activas);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_ca);
    final Integer idCategoria = getIntent().getIntExtra("EXTRA_POSITION",0);
    setupViewPager(viewPager,idCategoria);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerCA);
    // Adding menu icon to Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_ca));
    if (getSupportActionBar() != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        //getSupportActionBar().setHomeAsUpIndicator(indicator);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        Resources resources = getResources();
        String categoryName = ((resources.getStringArray(R.array.array_categories))[idCategoria].toString());
        getSupportActionBar().setTitle("Categoria: "+categoryName);
    }

}
 
Example 19
Project: PopCorn   File: AboutActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    setTitle(R.string.about);

    featureGraphicImageView = (ImageView) findViewById(R.id.image_view_feature_graphic_about);
    featureGraphicImageView.getLayoutParams().width = getResources().getDisplayMetrics().widthPixels;
    featureGraphicImageView.getLayoutParams().height = (int) ((double) getResources().getDisplayMetrics().widthPixels * (500.0 / 1024.0));

    shareImageButton = (ImageButton) findViewById(R.id.image_button_share_about);
    rateUsImageButton = (ImageButton) findViewById(R.id.image_button_rate_us_about);
    feedbackImageButton = (ImageButton) findViewById(R.id.image_button_feedback_about);

    sourceCodeOnGitHubCardView = (CardView) findViewById(R.id.card_view_source_code_on_github);

    openSourceLicensesFrameLayout = (FrameLayout) findViewById(R.id.frame_layout_open_source_licenses);
    versionNumberTextView = (TextView) findViewById(R.id.text_view_version_number);

    loadActivity();

}
 
Example 20
Project: betterHotels   File: BlogDetailActivity.java   View source code 6 votes vote down vote up
private void initializeToolbar() {
    final CollapsingToolbarLayout collapsingToolbar =
            (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("");
    Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);

    setSupportActionBar(mToolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("");
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
}
 
Example 21
Project: Java-9-Programming-Blueprints   File: WebLoginActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web_view);
    setTitle("Login");
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    Intent intent = getIntent();
    final String url = intent.getStringExtra("url");
    final String queryParam = intent.getStringExtra("queryParam");

    WebView webView = (WebView)findViewById(R.id.webView);
    final WebViewClient client = new LoginWebViewClient(queryParam);
    webView.setWebViewClient(client);
    webView.loadUrl(url);
}
 
Example 22
Project: Weather-Android   File: SettingsActivity.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(getTheme(PreferenceManager.getDefaultSharedPreferences(this).getString("theme", "fresh")));

    super.onCreate(savedInstanceState);

    LinearLayout root = (LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent();
    View bar = LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);
    root.addView(bar, 0);
    Toolbar toolbar = (Toolbar) findViewById(R.id.settings_toolbar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    addPreferencesFromResource(R.xml.prefs);
}
 
Example 23
Project: Snach-Android   File: DrawerHandler.java   View source code 6 votes vote down vote up
public DrawerHandler(Activity activity, Toolbar toolbar, boolean doActivateBluetooth, boolean doActivateGestures, boolean doActivateApps, boolean doActivateDevices) throws NullPointerException {
    this.activity = activity;
    this.toolbar = toolbar;

    getCurrentDevice();

    initializeDrawer();
    this.doActivateBluetooth = doActivateBluetooth;
    this.doActivateGestures = doActivateGestures;
    this.doActivateApps = doActivateApps;
    this.doActivateDevices = doActivateDevices;

    if(!doActivateBluetooth && !doActivateGestures && !doActivateApps && doActivateDevices){
        activateItemAtPosition(1);
    } else if(doActivateBluetooth && !doActivateGestures && !doActivateApps && !doActivateDevices){
        activateItemAtPosition(2);
    } else if(!doActivateBluetooth && doActivateGestures && !doActivateApps && !doActivateDevices){
        activateItemAtPosition(3);
    } else if(!doActivateBluetooth && !doActivateGestures && doActivateApps && !doActivateDevices){
        activateItemAtPosition(4);
    }
}
 
Example 24
Project: Crimson   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    viewPager = (ViewPager) findViewById(R.id.viewpager);
    setupViewPager(viewPager);

    tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    setupTabIcons();

}
 
Example 25
Project: Clipcon-AndroidClient   File: SettingsTutorialActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settings_tutorial_activity);

    Toolbar toolbar = (Toolbar) findViewById(R.id.settings_toolbar);
    toolbar.setTitle(R.string.settings_tutorial);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

}
 
Example 26
Project: Hillffair17   File: PastPolls.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_past_polls);
    Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    ab.setDisplayHomeAsUpEnabled(true);
    progressBar = (ProgressBar) findViewById(R.id.pollprogress);
    progressBar.setVisibility(View.VISIBLE);

    context=this;
    list = (RecyclerView) findViewById(R.id.listPoll);
    listPoll = new ArrayList<>();
    uid=new SharedPref(this).getUserId();
    getPastPoll();
}
 
Example 27
Project: MovieGuide   File: SearchActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    placeholderImage = ContextCompat.getDrawable(getApplicationContext(), R.drawable.disk_reel);
    RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.search_recycler_view);
    mSearchView = (SearchView) findViewById(R.id.search_view);

    setupActionBar();
    setupSearchView();

    List<MultiSearch.MultiSearchItem> searchItems = new ArrayList<>();
    mAdapter = new SearchAdapter(searchItems);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setAdapter(mAdapter);

    // Obtain the FirebaseAnalytics instance.
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
    ActivityUtils.firebaseAnalyticsLogEventSelectContent(mFirebaseAnalytics, PAGE_SEARCH, PAGE_SEARCH, TYPE_PAGE);
}
 
Example 28
Project: MyCalendar   File: MainActivity.java   View source code 5 votes vote down vote up
private void initView() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    mActionBar = getSupportActionBar();
    if (mActionBar != null) {
        mActionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar)));
    }

    if (mResources.getBoolean(R.bool.portrait_only)) {
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    mDrawerLayout = findViewById(R.id.activity_main_drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();

    navigationView = findViewById(R.id.activity_main_nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    View header = navigationView.getHeaderView(0);
    String text = "<font color=#009cdb>My</font> <font color=#47aa40>Ca</font><font color=#f67a20>len</font><font color=#ed2474>dar</font>";
    TextView text_nav_header = header.findViewById(R.id.activity_main_text_header);
    text_nav_header.setText(Html.fromHtml(text));


    mHoursScrollView = findViewById(R.id.activity_main_hours_scrollview);
    mWeekNumLabel = findViewById(R.id.activity_main_week_num_label);
    mWeekViewPager = findViewById(R.id.activity_main_week_view_view_pager);
    mCoordinatorHorizontalLine = findViewById(R.id.activity_main_coordinator_horizontal_line);
    mCoordinatorTextHour = findViewById(R.id.activity_main_text_hour_coordinator);
    mCoordinatorHolder = findViewById(R.id.activity_main_coordinator_holder);

    drawHourLabel();
    updateViewPager();
}
 
Example 29
Project: MaterialLearning   File: HorosActivity.java   View source code 5 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //将12个星座故事传入bundle键值对,方便取用
        bundle.putInt("双鱼座", R.string.Pisces);bundle.putInt("巨蟹座",R.string.Cancro);bundle.putInt("天蝎座",R.string.Scorpio);bundle.putInt("水瓶座",R.string.Aquarius);
        bundle.putInt("双子座",R.string.Gemini);bundle.putInt("天秤座",R.string.Libra);bundle.putInt("白羊座",R.string.Aries);bundle.putInt("狮子座",R.string.Leo);
        bundle.putInt("射手座",R.string.Sagit);bundle.putInt("金牛座",R.string.Taurus);bundle.putInt("处女座",R.string.Virgo);bundle.putInt("摩羯座",R.string.Capricorn);

        //获取各视图的对象,准备
        setContentView(R.layout.activity_horos);
        Toolbar toolbar=(Toolbar) findViewById(R.id.toolbar);
        CollapsingToolbarLayout collapsingToolbarLayout=(CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
        ImageView horoImage=(ImageView) findViewById(R.id.horo_image2);
        TextView horoStory = (TextView) findViewById(R.id.horo_story);
//从intent中取出图片id和字符
        Intent intent= getIntent();
        String horoName=  intent.getStringExtra(EN_NAME);
        int  horoImageId = intent.getIntExtra(IMAGE_ID,0);
        String cnName= intent.getStringExtra(CN_NAME);

//设置工具栏 返回键
        setSupportActionBar(toolbar);
        ActionBar actionBar=getSupportActionBar();
        if(actionBar!=null){
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
        //加载图片文字
        collapsingToolbarLayout.setTitle(horoName);
        Glide.with(this).load(horoImageId).into(horoImage);
        horoStory.setText(bundle.getInt(cnName));

    }
 
Example 30
Project: android-example   File: DetailMahasiswaDialog.java   View source code 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    bindView(view);

    Toolbar toolbar = view.findViewById(R.id.toolbar);
    toolbar.setTitle("Detail Mahasiswa");
    toolbar.setSubtitle(mahasiswa.Nama);
    toolbar.inflateMenu(R.menu.detail_menu);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {

            switch (item.getItemId()) {
                case R.id.detail_hapus:

                    callback.onDelete(mahasiswa);
                    getDialog().dismiss();
                    break;
                case R.id.detail_edit:

                    callback.onEdit(mahasiswa);
                    getDialog().dismiss();
                    break;
            }
            return false;
        }
    });
}
 
Example 31
Project: Android-DFU-App   File: SettingsActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(final Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_settings);

       final Toolbar toolbar  = (Toolbar) findViewById(R.id.toolbar_actionbar);
       setSupportActionBar(toolbar);
       getSupportActionBar().setDisplayHomeAsUpEnabled(true);

	// Display the fragment as the main content.
       getFragmentManager().beginTransaction().replace(R.id.content, new SettingsFragment()).commit();
}
 
Example 32
Project: polling-station-app   File: ManualInputActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manual_input);
    Toolbar appBar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(appBar);
    Util.setupAppBar(appBar, this);
    Typeface typeFace= Typeface.createFromAsset(getAssets(), "fonts/ro.ttf");

    docNumber = (EditText) findViewById(R.id.doc_num);
    docNumber.setTypeface(typeFace);
    TextView docNumTitle = (TextView) findViewById(R.id.doc_num_title);
    TextView dobTitle = (TextView) findViewById(R.id.dob_title);
    TextView expDateTitle = (TextView) findViewById(R.id.exp_date_title);
    docNumTitle.setTypeface(typeFace);
    dobTitle.setTypeface(typeFace);
    expDateTitle.setTypeface(typeFace);

    Button submitBut = (Button) findViewById(R.id.submit_button);
    submitBut.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if(verifyInput()) {
                Intent returnIntent = new Intent();
                returnIntent.putExtra(DocumentData.identifier, getData());
                setResult(Activity.RESULT_OK, returnIntent);
                finish();
            }
        }
    });
    setupDOBSpinners();
    setupExpirySpinners();

    // When docData was previously filled in, update text fields
    if(getIntent().hasExtra(DocumentData.identifier)) {
        putData(getIntent().getExtras());
    }
}
 
Example 33
Project: kolibri-android   File: ErrorActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_error);

  final Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  getSupportActionBar().setDisplayHomeAsUpEnabled(true);

  final TextView errorMessageTextView = findViewById(R.id.error_text);

  final Intent intent = getIntent();

  if (intent != null) {
    if (intent.hasExtra(Kolibri.EXTRA_ERROR_MESSAGE)) {
      final String message = intent.getStringExtra(Kolibri.EXTRA_ERROR_MESSAGE);
      errorMessageTextView.setText(message);
    }

    if (intent.hasExtra(Intent.EXTRA_TITLE)) {
      final String title = intent.getStringExtra(Intent.EXTRA_TITLE);
      getSupportActionBar().setTitle(title);
    }
  }

  Kolibri.getInstance(this).applyRuntimeTheme(false);
}
 
Example 34
Project: UnforgetIt   File: AddTaskDialogFragment.java   View source code 5 votes vote down vote up
@Override
protected void createMenu() {
    Toolbar toolbar = (Toolbar) mRootView.findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.add_title);

    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

    ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.ic_clear_white_24dp);
    }
}
 
Example 35
Project: musicplayer   File: RankInfoActivity.java   View source code 5 votes vote down vote up
private void initView() {
    //更改状态栏颜色为透明
    StatusBarUtils.setWindowStatusBarColor(RankInfoActivity.this,R.color.colorPrimaryDarkClarity);
    collapsingToolbarLayout= (CollapsingToolbarLayout) findViewById(R.id.collapsing_layout_toolbar);
    toolbar= (Toolbar) findViewById(R.id.toolbar_collapsing);
    homeback=findViewById(android.R.id.home);
    setSupportActionBar(toolbar);
    //显示左上角的返回按钮
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mLinear=new LinearLayoutManager(this);
    mrecyclerView= (RecyclerView) findViewById(R.id.recyclerview);

}
 
Example 36
Project: thermalprinterhelper   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    initUi();

    initProvider();
}
 
Example 37
Project: OracionesCatolicas   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.contenedor, new MainFragment()).commit();

    /*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 38
Project: ascii_generate   File: GalleryActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    setTitle(R.string.gallery);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    recyclerView = (RecyclerView) findViewById(R.id.recycle_view);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    loadImage();
}
 
Example 39
Project: cda-app   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //::::: Action Bar
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    //::::::: Action Split profile
    navigation_split_profile = (LinearLayout) findViewById(R.id.navigation_split_profile );
    navigation_split_profile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            nextLayout = new Intent(MainActivity.this, ProfileActivity.class);
            startActivity(nextLayout);
            finish();
        }
    });

    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);                                    //to add a listener and

    // Split Menu - (open split)
    MenuSplit();

    //:::FRAGMENT
    if (savedInstanceState == null)
        positionSplit = 0;

    selectFragment(positionSplit);
}
 
Example 40
Project: Anagram   File: AnagramsActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_anagrams);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    AssetManager assetManager = getAssets();
    try {
        InputStream inputStream = assetManager.open("words.txt");
        dictionary = new AnagramDictionary(new InputStreamReader(inputStream));
    } catch (IOException e) {
        Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG);
        toast.show();
    }
    // Set up the EditText box to process the content of the box when the user hits 'enter'
    final EditText editText = (EditText) findViewById(R.id.editText);
    editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
    editText.setImeOptions(EditorInfo.IME_ACTION_GO);
    editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_GO) {
                processWord(editText);
                handled = true;
            }
            return handled;
        }
    });
}