下面列出了android.app.ActionBar#setDisplayHomeAsUpEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_service_list);
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_HOME);
actionBar.setTitle(R.string.activity_service_list_title);
}
mManualActivity = getSettingManualActivityClass();
bindMessageService();
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Resources resource = getResources();
// set name of actionbar.
ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(resource.getString(R.string.prefTitle_Developer));
}
// load default value
PreferenceManager.setDefaultValues(getActivity(), R.xml.pref_developer_setting, false);
// config xml
addPreferencesFromResource(R.xml.pref_developer_setting);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
Settings settings = Settings.getInstance(this);
if (settings.isDarkTheme()) {
setTheme(android.R.style.Theme_Material);
}
super.onCreate(savedInstanceState);
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setSubtitle(R.string.app_name);
}
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_packages_selector_content);
final Intent intent = getIntent();
if (intent != null) {
mLastSelectedPackages = intent.getStringArrayListExtra(EXTRA_SELECTED);
}
final ActionBar actionBar = requireNonNull(getActionBar());
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_close_black_24dp);
mRecyclerView = findViewById(android.R.id.list);
mProgressBar = findViewById(android.R.id.progress);
mAdapter.onRestoreInstanceState(savedInstanceState);
mRecyclerView.setAdapter(mAdapter);
if (savedInstanceState == null) {
loadAppInfoListAsync();
}
}
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference)
{
boolean result =
super.onPreferenceTreeClick(preferenceScreen, preference);
// Set home as up
if (preference instanceof PreferenceScreen)
{
Dialog dialog = ((PreferenceScreen) preference).getDialog();
ActionBar actionBar = dialog.getActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
}
return result;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
Intent intent = getIntent();
String title = intent.getStringExtra(getString(R.string.webview_intent_title));
String subTitle = intent.getStringExtra(getString(R.string.webview_intent_subtitle));
ActionBar actionBar = getActionBar();
actionBar.setTitle(title);
actionBar.setSubtitle(subTitle);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
fragment = (WebViewFragment) getSupportFragmentManager().findFragmentById(R.id.webview_fragment);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent,
Bundle savedInstanceState) {
super.onCreateView(inflater, parent, savedInstanceState);
WebView v = new WebView(getActivity());
ActionBar ab = getActivity().getActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
ab.setHomeButtonEnabled(true);
}
return v;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
// view.setBackgroundColor(getResources().getColor(R.color.prefBkg_CameraResource));
// set name of actionbar.
ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(getResources().getString(R.string.prefTitle_CameraSource));
}
return view;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_order);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
}
private void setupActionBarAttributes() {
final ActionBar actionBar = getActionBar();
if (actionBar == null) {
return;
}
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reply_preview_activity);
ActionBar ab = getActionBar();
if(ab != null){
ab.setHomeButtonEnabled(true);
ab.setDisplayHomeAsUpEnabled(true);
}
}
private void renderBlockDetail(final BlockInfoEx blockInfo) {
ListAdapter listAdapter = mListView.getAdapter();
final DetailAdapter adapter;
if (listAdapter instanceof DetailAdapter) {
adapter = (DetailAdapter) listAdapter;
} else {
adapter = new DetailAdapter();
mListView.setAdapter(adapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
adapter.toggleRow(position);
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
invalidateOptionsMenu();
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
mActionButton.setVisibility(VISIBLE);
mActionButton.setText(R.string.block_canary_delete);
}
mActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (blockInfo != null) {
blockInfo.logFile.delete();
mBlockStartTime = null;
mBlockInfoEntries.remove(blockInfo);
updateUi();
}
}
});
adapter.update(blockInfo);
setTitle(getString(R.string.block_canary_class_has_blocked, blockInfo.timeCost));
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
// set name of actionbar.
ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(getResources().getString(R.string.prefTitle_System));
}
return view;
}
@Override
protected void onCreate(final Bundle savedState) {
super.onCreate(savedState);
final ActionBar actionBar = getActionBar();
final Intent intent = getIntent();
if (actionBar != null) {
mShowHomeAsUp = intent.getBooleanExtra(EXTRA_SHOW_HOME_AS_UP, true);
actionBar.setDisplayHomeAsUpEnabled(mShowHomeAsUp);
actionBar.setHomeButtonEnabled(mShowHomeAsUp);
}
StatsUtils.onSettingsActivity(
intent.hasExtra(EXTRA_ENTRY_KEY) ? intent.getStringExtra(EXTRA_ENTRY_KEY)
: EXTRA_ENTRY_VALUE_SYSTEM_SETTINGS);
}
@Override
protected void onCreate(final Bundle savedState) {
super.onCreate(savedState);
final ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
}
}
public static void setupActionBar(Activity activity) {
// Tint the status bar, if available.
SystemBarTintManager tintManager = new SystemBarTintManager(activity);
tintManager.setStatusBarTintEnabled(true);
tintManager.setTintColor(activity.getResources().getColor(R.color.action_bar_dark));
ActionBar actionBar = activity.getActionBar();
if (null != actionBar) {
actionBar.setIcon(DateUtils.AppIcon());
actionBar.setDisplayHomeAsUpEnabled(!activity.isTaskRoot());
actionBar.setDisplayShowTitleEnabled(true);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
setContentView(R.layout.show_locaction_activity);
MapFragment fragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map_fragment);
fragment.getMapAsync(this);
}
@Override
protected void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.a_example_details);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ActionBar ab = getActionBar();
if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
}
}
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_licenses);
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
webView = (WebView) findViewById(R.id.webView);
webView.loadUrl("file:///android_res/raw/licenses.html");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
}