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

The following are Jave code examples for showing how to use setDisplayShowHomeEnabled() of the android.support.v7.app.ActionBar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: rebase-android   File: ToolbarActivity.java   Source Code and License Vote up 6 votes
private void init() {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setDisplayHomeAsUpEnabled(true);
            /* NOTE: Hide the origin title view */
            actionBar.setDisplayShowTitleEnabled(false);
        }
    } else {
        Log.e(TAG, "Toolbar == null");
    }
}
 
Example 2
Project: rebase-android   File: ToolbarActivity.java   Source Code and License Vote up 6 votes
@Override
public void setContentView(@LayoutRes int layoutResID) {
    super.setContentView(layoutResID);
    ButterKnife.bind(holder, this);
    toolbar = holder.toolbar;

    if (toolbar != null) {
        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressed();
            }
        });
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayShowHomeEnabled(true);
            if (canBack()) {
                getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            }
        }
    }
}
 
Example 3
Project: liveomvp   File: BaseActivity.java   Source Code and License Vote up 6 votes
public void onInitToolbar(Toolbar toolBar, String title, int icon, boolean displayHome) {

        if (toolBar != null) {
            setSupportActionBar(toolBar);
            ActionBar actionBar = getSupportActionBar();

            if (actionBar != null) {
                actionBar.setTitle(title);
                actionBar.setDisplayShowHomeEnabled(displayHome);
                actionBar.setDisplayHomeAsUpEnabled(displayHome);
                if (icon != -1 && displayHome) {
                    toolBar.setNavigationIcon(ContextCompat.getDrawable(this, icon));
                }
            }
        }
    }
 
Example 4
Project: couch-potatoes   File: UserGalleryActivity.java   Source Code and License Vote up 6 votes
/**
 * Sets up the swipe gallery
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.user_gallery);

    // Creates a back button on the action bar
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Instantiate a ViewPager and a PagerAdapter.
    mPager = (ViewPager) findViewById(R.id.gallery);
    mPagerAdapter = new UserGalleryAdapter(getSupportFragmentManager());
    mPager.setAdapter(mPagerAdapter);
}
 
Example 5
Project: Android-AudioRecorder-App   File: PlayListActivity.java   Source Code and License Vote up 6 votes
@Override public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_record_list);
  Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  ActionBar actionBar = getSupportActionBar();
  if (actionBar != null) {
    actionBar.setTitle(R.string.tab_title_saved_recordings);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);
  }
  setNavBarColor();

  if (savedInstanceState == null) {
    getSupportFragmentManager().beginTransaction()
        .add(R.id.record_list_container, PlayListFragment.newInstance())
        .commit();
  }
}
 
Example 6
Project: Companion-For-PUBG-Android   File: ItemDetailActivity.java   Source Code and License Vote up 6 votes
@Override
public void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setSupportActionBar(toolbar);

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }

    final Intent intent = getIntent();
    if (intent == null) {
        throw new IllegalStateException("Missing intent");
    }
    final Item item = (Item) intent.getSerializableExtra(EXTRA_ITEM);
    if (item instanceof Weapon) {
        showFragment(WeaponDetailFragment.newInstance((Weapon) item), WeaponDetailFragment.TAG);
    } else if (item instanceof Ammo) {
        showFragment(AmmoDetailFragment.newInstance((Ammo) item), WeaponDetailFragment.TAG);
    } else {
        Toast.makeText(this, "We're still working on this feature!", Toast.LENGTH_SHORT).show();
        finish();
    }
}
 
Example 7
Project: Companion-For-PUBG-Android   File: NewsDetailActivity.java   Source Code and License Vote up 6 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setSupportActionBar(toolbar);

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }

    final Intent intent = getIntent();
    if (intent == null) {
        throw new IllegalStateException("Missing intent");
    }
    final String newsItemSrc = intent.getStringExtra(EXTRA_NEWSITEM_SRC);
    showFragment(NewsDetailFragment.newInstance(newsItemSrc), NewsDetailFragment.TAG);

}
 
Example 8
Project: LifeSaver   File: Main4Activity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar actionBar=getSupportActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back_black_24dp);
    actionBar.setDisplayShowHomeEnabled(true);
    setContentView(R.layout.activity_main4);
    go();
}
 
Example 9
Project: sample-code-posts   File: AbstractAppActivity.java   Source Code and License Vote up 5 votes
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
protected void setToolbar(final Toolbar toolbar) {
    setSupportActionBar(toolbar);
    @Nullable final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    } else {
        Timber.w("Cannot get an action bar for this activity; verify that this activity has actually defined a toolbar.");
    }
}
 
Example 10
Project: TVGuide   File: MainActivity.java   Source Code and License Vote up 5 votes
private void setupToolBar() {
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }
    updateChannelView();
}
 
Example 11
Project: Tusky   File: SavedTootActivity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_saved_toot);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        bar.setTitle(getString(R.string.title_saved_toot));
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setDisplayShowHomeEnabled(true);
    }

    RecyclerView recyclerView = findViewById(R.id.recycler_view);
    noContent = findViewById(R.id.no_content);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    DividerItemDecoration divider = new DividerItemDecoration(
            this, layoutManager.getOrientation());
    Drawable drawable = ThemeUtils.getDrawable(this, R.attr.status_divider_drawable,
            R.drawable.status_divider_dark);
    divider.setDrawable(drawable);
    recyclerView.addItemDecoration(divider);
    adapter = new SavedTootAdapter(this);
    recyclerView.setAdapter(adapter);
}
 
Example 12
Project: PCController-android   File: ShowPictureActivity.java   Source Code and License Vote up 5 votes
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_showpic);
    ButterKnife.bind(this);
    setSupportActionBar(toolbar);
    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setTitle("图片");
        ab.setDisplayHomeAsUpEnabled(true);
        ab.setDisplayShowHomeEnabled(true);
    }
    bitmap = getIntent().getParcelableExtra("img");
    mPhotoView.setImageBitmap(bitmap);
}
 
Example 13
Project: Ocr-android   File: MainActivity.java   Source Code and License Vote up 5 votes
@Override
public void onShow(String title) {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(title);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }
}
 
Example 14
Project: NodeET   File: TopicListActivity.java   Source Code and License Vote up 5 votes
private void setUpToolbar() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(mCategoryName);
    setSupportActionBar(toolbar);
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        //make Android Studio happy
        supportActionBar.setDisplayHomeAsUpEnabled(true);
        supportActionBar.setDisplayShowHomeEnabled(true);
    }
    toolbar.setNavigationOnClickListener(v -> finish());
}
 
Example 15
Project: Synapse   File: ModelDetailActivity.java   Source Code and License Vote up 5 votes
private void setUpActionBar() {
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }
}
 
Example 16
Project: Ocr-android   File: MainActivity.java   Source Code and License Vote up 5 votes
@Override
public void onHide() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(R.string.app_name);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayShowHomeEnabled(false);
    }
}
 
Example 17
Project: Nird2   File: BriarActivity.java   Source Code and License Vote up 5 votes
/**
 * This should be called after the content view has been added in onCreate()
 *
 * @param ownLayout true if the custom toolbar brings its own layout
 * @return the Toolbar object or null if content view did not contain one
 */
@Nullable
protected Toolbar setUpCustomToolbar(boolean ownLayout) {
	// Custom Toolbar
	Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
	setSupportActionBar(toolbar);
	ActionBar ab = getSupportActionBar();
	if (ab != null) {
		ab.setDisplayShowHomeEnabled(true);
		ab.setDisplayHomeAsUpEnabled(true);
		ab.setDisplayShowCustomEnabled(ownLayout);
		ab.setDisplayShowTitleEnabled(!ownLayout);
	}
	return toolbar;
}
 
Example 18
Project: PCController-android   File: BaseActivity.java   Source Code and License Vote up 5 votes
public void setupActionBar(Toolbar toolbar, boolean canBack) {
    setSupportActionBar(toolbar);
    if (canBack) {
        ActionBar actionBar = getSupportActionBar();
        if (actionBar == null) return;
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }
}
 
Example 19
Project: TrackPlan-app   File: Main99Activity.java   Source Code and License Vote up 4 votes
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main99);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        ActionBar actionBar=getSupportActionBar();
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.ic_arrow_back_black_24dp);
        actionBar.setDisplayShowHomeEnabled(true);
        stringArrayList= new ArrayList<String>();

        DesertPlaceholder desertPlaceholder = (DesertPlaceholder) findViewById(R.id.placeholder);
        desertPlaceholder.setOnButtonClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // do stuff

            }
        });



        listView=(ListView) findViewById(R.id.listView65);

        checkdata();
        lviewAdapter=new ListViewAdapterAttendance(this,stringArrayList);
        listView.setAdapter(lviewAdapter);
        TextView t=(TextView)findViewById(R.id.textView59);
if(lviewAdapter.isEmpty())
{t.setVisibility(View.INVISIBLE);
   desertPlaceholder.setVisibility(View.VISIBLE);
}
else {
    desertPlaceholder.setVisibility(View.GONE);
t.setVisibility(View.VISIBLE);
}







    }
 
Example 20
Project: simple-stack   File: MainActivity.java   Source Code and License Vote up 4 votes
/**
 * Pay attention to the {@link #setContentView} call here. It's creating a responsive layout
 * for us.
 * <p>
 * Notice that the app has two root_layout files. The main one, in {@code res/layout} is used by
 * mobile devices and by tablets in portrait orientation. It holds a generic {@link
 * com.example.stackmasterdetailfrag.util.pathview.SinglePaneRoot}.
 * <p>
 * The interesting one, loaded by tablets in landscape mode, is {@code res/layout-sw600dp-land}.
 * It loads a {@link TabletMasterDetailRoot}, with a master list on the
 * left and a detail view on the right.
 * <p>
 * But this master activity knows nothing about those two view types. It only requires that
 * the view loaded by {@code root_layout.xml} implements the StateChanger interface,
 * to render whatever is appropriate for the screens received from {@link com.zhuinden.simplestack.Backstack} via
 * {@link #handleStateChange}.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowHomeEnabled(false);
    backstackDelegate = new BackstackDelegate(null);
    backstackDelegate.setStateClearStrategy(new MasterDetailStateClearStrategy());
    backstackDelegate.onCreate(savedInstanceState,
            getLastCustomNonConfigurationInstance(), HistoryBuilder.single(ConversationListPath.create()));
    backstackDelegate.registerForLifecycleCallbacks(this);
    setContentView(R.layout.root_layout);
    container = (StateChanger) findViewById(R.id.container);
    containerAsBackTarget = (HandlesBack) container;
    backstackDelegate.setStateChanger(this);
}