Java Code Examples for android.support.v7.app.ActionBar#setHomeAsUpIndicator()

The following examples show how to use android.support.v7.app.ActionBar#setHomeAsUpIndicator() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Override
protected final void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setSupportActionBar(toolbar);

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    if (this.navigationView != null) {
        this.navigationView.setNavigationItemSelectedListener(this);
        this.navigationView.setCheckedItem(R.id.drawer_map);
    }
    mapSelected();
}
 
Example 2
Source Project: androidtestdebug   File: NotesActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_notes);


    // Set up the toolbar.
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    // Set up the navigation drawer.
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

    if (null == savedInstanceState) {
        initFragment(NotesFragment.newInstance());
    }
}
 
Example 3
Source Project: px-android   File: ToolbarCancel.java    License: MIT License 5 votes vote down vote up
private void init() {
    final Activity activity = getActivity();
    if (activity instanceof AppCompatActivity) {
        final AppCompatActivity appCompatActivity = (AppCompatActivity)activity;
        appCompatActivity.setSupportActionBar(this);
        final ActionBar supportActionBar = appCompatActivity.getSupportActionBar();
        supportActionBar.setHomeAsUpIndicator(R.drawable.ic_close);
        supportActionBar.setHomeActionContentDescription(R.string.px_label_close);
        supportActionBar.setDisplayHomeAsUpEnabled(true);
        supportActionBar.setDisplayShowTitleEnabled(false);
        setNavigationOnClickListener(v -> appCompatActivity.onBackPressed());
    }
}
 
Example 4
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.statistics_act);

  // Set up the toolbar.
  Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  ActionBar ab = getSupportActionBar();
  ab.setTitle(R.string.statistics_title);
  ab.setHomeAsUpIndicator(R.drawable.ic_menu);
  ab.setDisplayHomeAsUpEnabled(true);

  // Set up the navigation drawer.
  mDrawerLayout = findViewById(R.id.drawer_layout);
  mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
  NavigationView navigationView = findViewById(R.id.nav_view);
  if (navigationView != null) {
    setupDrawerContent(navigationView);
  }

  StatisticsFragment statisticsFragment =
      (StatisticsFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
  if (statisticsFragment == null) {
    statisticsFragment = StatisticsFragment.newInstance();
    ActivityUtils.addFragmentToActivity(
        getSupportFragmentManager(), statisticsFragment, R.id.contentFrame);
  }
}
 
Example 5
Source Project: GraphView   File: GraphActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void setupToolbar() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setHomeAsUpIndicator(R.drawable.ic_arrow_back);
        ab.setDisplayHomeAsUpEnabled(true);
    }
}
 
Example 6
private void initToolbar(){
    Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
    toolbar.setTitle("");
    TextView toolbar_title = (TextView) findViewById(R.id.toolbar_title);
    toolbar_title.setText("信息反馈");
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.icon_back);
    }
}
 
Example 7
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collapsing_toolbar_layout);
    ButterKnife.bind(this);

    setSupportActionBar(toolBar);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setHomeAsUpIndicator(android.R.drawable.ic_input_delete);
    actionBar.setDisplayHomeAsUpEnabled(true);

    collapsingToolbar.setTitle("详情界面");
}
 
Example 8
private void setUpToolBar() {
  Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
  toolbar.setTitle("");
  TextView titleTextView = toolbar.findViewById(R.id.toolbar_title);
  titleTextView.setText("App Details");
  ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
  ActionBar supportActionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
  supportActionBar.setDisplayHomeAsUpEnabled(true);
  supportActionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white);
}
 
Example 9
@Override
public void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setHomeAsUpIndicator(R.drawable.icon_back);
    }


    mViewPager = (ViewPager) findViewById(R.id.vp_pic);

}
 
Example 10
Source Project: RetroFacebook   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.inject(this);

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

    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Here's a Snackbar", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}
 
Example 11
private void initToolbar(){
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.icon_back);
    }
}
 
Example 12
@Override
protected void onCreate(Bundle savedInstanceState)
{
    setTheme(AppSettings.loadTheme(this));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_activity_about);

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

    int icon = R.drawable.ic_action_suntimes;
    Intent intent = getIntent();
    if (intent != null) {
        icon = intent.getIntExtra(EXTRA_ICONID, icon);
    }

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(icon);
    }

    pagerAdapter = new AboutPagerAdapter(getSupportFragmentManager());
    viewPager = (ViewPager) findViewById(R.id.container);
    viewPager.setAdapter(pagerAdapter);

    tabs = (TabLayout) findViewById(R.id.tabs);
    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabs));
    tabs.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager));

    viewPager.post(new Runnable() {
        @Override
        public void run() {
            AppSettings.checkCustomPermissions(AboutActivity.this);
        }
    });
}
 
Example 13
private void setUpToolBar() {
  Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
  toolbar.setTitle("");
  titleTextView = toolbar.findViewById(R.id.toolbar_title);
  ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
  ActionBar supportActionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
  supportActionBar.setDisplayHomeAsUpEnabled(true);
  supportActionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back_white);
}
 
Example 14
Source Project: Loop   File: ExploreFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

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

    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if(ab != null){
        ab.setHomeAsUpIndicator(R.drawable.ic_menu_light);
        ab.setDisplayHomeAsUpEnabled(true);
        ab.setTitle(TrestleUtility.getFormattedText(getString(R.string.explore), font));
    }

    LinearLayoutManager layoutManager = new GridLayoutManager(getActivity(), 2);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(new GridSpacesItemDecoration(DisplayUtility.dp2px(getActivity(), 8)));

    categoriesAdapter = new CategoriesAdapter();
    categoriesAdapter.setOnItemClickListener(this);

    recyclerView.setItemAnimator(new SlideInUpAnimator());
    recyclerView.setAdapter(categoriesAdapter);

    Call getCategoriesCall = vimeoService.getCategories();
    calls.add(getCategoriesCall);
    getCategoriesCall.enqueue(getCategoriesCallback);
}
 
Example 15
Source Project: CoreModule   File: BrowserActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.browser_activity_layout);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.mipmap.browser_icon_delete);
    }
    initData();
}
 
Example 16
public void setupToolbar() {
    Toolbar toolbar = findViewById(R.id.scan_toolbar);
    setSupportActionBar(toolbar);

    final ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setDisplayHomeAsUpEnabled(true);
        ab.setDisplayShowTitleEnabled(false);
        ab.setHomeAsUpIndicator(R.drawable.ic_close_white);
    }
}
 
Example 17
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tasks_act);

    // Set up the toolbar.
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    // Set up the navigation drawer.
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

    TasksFragment tasksFragment =
            (TasksFragment) getSupportFragmentManager().findFragmentById(R.id.contentFrame);
    if (tasksFragment == null) {
        // Create the fragment
        tasksFragment = TasksFragment.newInstance();
        ActivityUtils.addFragmentToActivity(
                getSupportFragmentManager(), tasksFragment, R.id.contentFrame);
    }

    // Create the presenter
    mTasksPresenter = new TasksPresenter(
            Injection.provideTasksRepository(getApplicationContext()), tasksFragment);

    // Load previously saved state, if available.
    if (savedInstanceState != null) {
        TasksFilterType currentFiltering =
                (TasksFilterType) savedInstanceState.getSerializable(CURRENT_FILTERING_KEY);
        mTasksPresenter.setFiltering(currentFiltering);
    }
}
 
Example 18
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.statistics_act);

    // Set up the toolbar.
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    ab.setTitle(R.string.statistics_title);
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    // Set up the navigation drawer.
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

    StatisticsFragment statisticsFragment = (StatisticsFragment) getSupportFragmentManager()
            .findFragmentById(R.id.contentFrame);
    if (statisticsFragment == null) {
        statisticsFragment = StatisticsFragment.newInstance();
        ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),
                statisticsFragment, R.id.contentFrame);
    }

    new StatisticsPresenter(
            Injection.provideTasksRepository(getApplicationContext()), statisticsFragment);
}
 
Example 19
private void setupToolbar() {
    final ActionBar ab = getActionBarToolbar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
}
 
Example 20
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation_view);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.id_drawer_layout);
    mNavigationView = (NavigationView) findViewById(R.id.id_nv_menu);


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

    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    setupDrawerContent(mNavigationView);


}