下面列出了android.app.ActionBar#setDisplayShowHomeEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar actionBar = getActionBar();
actionBar.setTitle(R.string.app_name);
actionBar.setSubtitle(null);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setHomeButtonEnabled(false);
fragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.main_fragment);
search = (AutoCompleteTextView) findViewById(R.id.main_header_search);
View line = findViewById(R.id.main_header_line);
fragment.setSearch(search);
fragment.setLine(line);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ActionBar actionBar = getActionBar();
actionBar.setTitle(R.string.app_name);
actionBar.setSubtitle(null);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setHomeButtonEnabled(false);
fragment = (MainFragment) getSupportFragmentManager().findFragmentById(R.id.main_fragment);
preferences = getSharedPreferences(getString(R.string.login_sp), MODE_PRIVATE);
editor = preferences.edit();
layoutParams = getWindow().getAttributes();
search = (AutoCompleteTextView) findViewById(R.id.main_header_search);
View line = findViewById(R.id.main_header_line);
fragment.setSearch(search);
fragment.setLine(line);
}
private void configureActionbar(){
ActionBar bar = getActionBar();
bar.setHomeButtonEnabled(true);
bar.setDisplayShowHomeEnabled(false);
tint = new SystemBarTintManager(this);
TypedValue tintColor = new TypedValue();
if(getTheme().resolveAttribute(R.attr.statusBarBackground, tintColor, true)){
tint.setStatusBarTintEnabled(true);
tint.setTintColor(tintColor.data);
defaultActionbarColor = tintColor.data;
currentActionbarColor = tintColor.data;
}else{
tint.setStatusBarTintEnabled(false);
}
TypedValue actionbarBackground = new TypedValue();
if(getTheme().resolveAttribute(R.attr.actionbarBackgroundLayerList, actionbarBackground, false)){
actionbarBackgroundList = (LayerDrawable) getResources().getDrawable(actionbarBackground.data);
actionbarBackgroundList.mutate();
actionbarColor = (ColorDrawable) actionbarBackgroundList.findDrawableByLayerId(R.id.actionbar_background_color);
actionbarColor.mutate();
bar.setBackgroundDrawable(actionbarBackgroundList);
}
}
/**
* Goes back to usual Phone UI with tags. Previously selected Tag and associated Fragment
* should be automatically focused again.
*/
private void exitSearchUi() {
final ActionBar actionBar = getActionBar();
// Hide the search fragment, if exists.
if (mSearchFragment != null) {
mSearchFragment.setUserVisibleHint(false);
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.hide(mSearchFragment);
transaction.commitAllowingStateLoss();
}
// We want to hide SearchView and show Tabs. Also focus on previously selected one.
actionBar.setDisplayShowCustomEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
for (int i = 0; i < TAB_INDEX_COUNT; i++) {
sendFragmentVisibilityChange(i, i == mViewPager.getCurrentItem());
}
// Before exiting the search screen, reset swipe state.
mDuringSwipe = false;
mUserTabClick = false;
mViewPager.setVisibility(View.VISIBLE);
hideInputMethod(getCurrentFocus());
// Request to update option menu.
invalidateOptionsMenu();
// See comments in onActionViewExpanded()
mSearchView.onActionViewCollapsed();
mInSearchUi = false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null && savedInstanceState.getInt("theme", -1) != -1) {
mThemeId = savedInstanceState.getInt("theme");
this.setTheme(mThemeId);
}
setContentView(R.layout.main);
Directory.initializeDirectory(new OnDirectoryChanged());
ActionBar bar = getActionBar();
int i;
for (i = 0; i < Directory.getCategoryCount(); i++) {
bar.addTab(bar.newTab().setText(Directory.getCategory(i).getName())
.setTabListener(this));
}
mActionBarView = getLayoutInflater().inflate(
R.layout.action_bar_custom, null);
bar.setCustomView(mActionBarView);
bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayShowHomeEnabled(true);
// If category is not saved to the savedInstanceState,
// 0 is returned by default.
if(savedInstanceState != null) {
int category = savedInstanceState.getInt("category");
bar.selectTab(bar.getTabAt(category));
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
ThemeUtils.processSetTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.fsiva_main);
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
}
Intent intent = getIntent();
if (intent != null) {
ImageView fsiva_main_imageView = findViewById(R.id.fsiva_main_imageView);
fsiva_main_imageView.setImageBitmap(
BitmapFactory.decodeFile(intent.getStringExtra("imgPath"))
);
fsiva_main_imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
} else {
finish();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Customize the action bar
ActionBar actionBar = getActionBar();
if(actionBar != null) {
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.header, null);
Typeface scriptFont = Typeface.createFromAsset(getAssets(), "fonts/script.ttf");
TextView title = (TextView) v.findViewById(R.id.title);
title.setTypeface(scriptFont);
actionBar.setCustomView(v);
}
//Initialize Views
postListView = (AnimatedListView) findViewById(R.id.post_list);
postListView.setOnItemClickListener(postItemSelectedListener);
progressBar = (ProgressBar) findViewById(R.id.loader);
//Register as a Post List update listener
KWBApplication application = (KWBApplication) getApplication();
application.registerPostUpdateListener(this);
}
@Override @TargetApi(14)
protected void setActionBarSettings(Activity activity) {
ActionBar actionBar = activity.getActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setIcon(getDrawable());
}
@Override @TargetApi(14)
protected void setActionBarSettings(Activity activity) {
ActionBar actionBar = activity.getActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setIcon(getDrawable());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
setContentView(R.layout.activity_feedback);
content = (EditText) findViewById(R.id.edit_fb);
qq = (EditText) findViewById(R.id.edit_fb_qq);
}
private void initView() {
ActionBar actionBar = this.getActionBar();
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
setOverflowShowingAlways();
mFragmentManager = getFragmentManager();
mRg_tab = (RadioGroup) findViewById(R.id.cgt_rg_tab);
mRg_tab.setOnCheckedChangeListener(this);
}
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.preferences);
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeButtonEnabled(true);
actionBar.setLogo(this.getResources().getDrawable(R.drawable.ic_action_up));
actionBar.setDisplayUseLogoEnabled(true);
addPreferencesFromResource(R.xml.preferences);
// lockScreenMode = (ListPreference) findPreference(Preferences.Keys.LOCK_SCREEN_MODE);
// updateSummaryWithChoice(lockScreenMode, lockScreenMode.getValue(), getResources().getStringArray(R.array.lockScreenOptions_));
language = (ListPreference) findPreference(Preferences.Keys.LANGUAGE);
updateSummaryWithChoice(language, language.getValue(), getResources().getStringArray(R.array.languages_));
//originalImage = (ListPreference) findPreference(Models.IUser.ASSET_ENCRYPTION);
//updateSummaryWithChoice(originalImage, originalImage.getValue(), getResources().getStringArray(R.array.originalImageOptions_));
panicAction = (ListPreference) findPreference(Preferences.Keys.PANIC_ACTION);
updateSummaryWithChoice(panicAction, panicAction.getValue(), getResources().getStringArray(R.array.panicActionOptions_));
}
public void initializeView() {
ActionBar bar = getActionBar();
bar.setDisplayShowHomeEnabled(true);
bar.setDisplayShowTitleEnabled(false);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
viewPager = (ViewPager) findViewById(R.id.viewPager);
pagerAdapter = new PageListAdapter(this, viewPager);
initializePages();
}
private void initView() {
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(R.string.text_menu_userDetailedInfo_title);
setOverflowShowingAlways();
mIv_userPhoto = (ImageView) findViewById(R.id.cgt_iv_userDetailedInfo_userPhoto);
mTv_userName = (TextView) findViewById(R.id.cgt_tv_userDetailedInfo_userName);
mIv_userSex = (ImageView) findViewById(R.id.cgt_iv_userDetailedInfo_userSex);
mTv_userWeixin = (TextView) findViewById(R.id.cgt_tv_userDetailedInfo_userWeixin);
mTv_nickName = (TextView) findViewById(R.id.cgt_tv_userDetailedInfo_nickname);
mTv_area = (TextView) findViewById(R.id.cgt_tv_userDetailedInfo_area);
mTv_personalizedSignature = (TextView) findViewById(R.id.cgt_tv_userDetailedInfo_personalizedSignature);
mLl_personalPhoto_box = (LinearLayout) findViewById(R.id.cgt_ll_userDetailedInfo_personalPhoto_box);
mLl_personalPhoto = (LinearLayout) findViewById(R.id.cgt_ll_userDetailedInfo_personalPhoto);
mLl_socialInfo_box = (LinearLayout) findViewById(R.id.cgt_ll_userDetailedInfo_socialInfo_box);
mLl_socialInfo = (LinearLayout) findViewById(R.id.cgt_ll_userDetailedInfo_socialInfo);
mBtn_sendMsg = (Button) findViewById(R.id.cgt_btn_userDetailedInfo_sendMsg);
mBtn_videoChat = (Button) findViewById(R.id.cgt_btn_userDetailedInfo_videoChat);
mIv_userPhoto.setOnClickListener(this);
mLl_personalPhoto_box.setOnClickListener(this);
mLl_socialInfo_box.setOnClickListener(this);
mBtn_sendMsg.setOnClickListener(this);
mBtn_videoChat.setOnClickListener(this);
}
protected void onCreate(Bundle bundle)
{
super.onCreate(bundle);
FragmentTransaction fragmenttransaction = getFragmentManager().beginTransaction();
a = (SettingFirmwareFragment)Fragment.instantiate(this, cn/com/smartdevices/bracelet/ui/SettingFirmwareActivity$SettingFirmwareFragment.getName());
fragmenttransaction.add(0x1020002, a);
fragmenttransaction.commit();
ActionBar actionbar = getActionBar();
actionbar.setDisplayHomeAsUpEnabled(true);
actionbar.setDisplayShowHomeEnabled(false);
actionbar.setDisplayUseLogoEnabled(false);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sharedPreferences = new FanfanSharedPreferences(MainActivity.this);
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowHomeEnabled(false);
if (!sharedPreferences.getLogInStatus(false)) {
draweritems = this.getResources().getStringArray(
R.array.nologindrawerliststring);
} else {
draweritems = this.getResources().getStringArray(
R.array.drawerliststring);
// Login();
}
mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager()
.findFragmentById(R.id.navigation_drawer);
mTitle = getTitle();
// Set up the drawer.
mNavigationDrawerFragment.setUp(R.id.navigation_drawer,
(DrawerLayout) findViewById(R.id.drawer_layout));
// ���������Զ��������
UmengUpdateAgent.update(MainActivity.this);
// �û���������̨����Ƿ����µ����Կ����ߵĻظ���
FeedbackAgent mAgent = new FeedbackAgent(MainActivity.this);
mAgent.sync();
MobclickAgent.updateOnlineConfig(MainActivity.this);
}
private void configureSimpleNav(Activity activity, ActionBar actionBar) {
boolean showNav = true;
if (activity instanceof CommCareActivity) {
showNav = ((CommCareActivity)activity).isBackEnabled();
}
if (showNav) {
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
}
actionBar.setDisplayShowTitleEnabled(true);
String title = getBestTitle(activity);
actionBar.setTitle(title);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null && savedInstanceState.getInt("theme", -1) != -1) {
mThemeId = savedInstanceState.getInt("theme");
this.setTheme(mThemeId);
}
setContentView(R.layout.main);
Directory.initializeDirectory(new OnDirectoryChanged());
ActionBar bar = getActionBar();
int i;
for (i = 0; i < Directory.getCategoryCount(); i++) {
bar.addTab(bar.newTab().setText(Directory.getCategory(i).getName())
.setTabListener(this));
}
mActionBarView = getLayoutInflater().inflate(
R.layout.action_bar_custom, null);
bar.setCustomView(mActionBarView);
bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayShowHomeEnabled(true);
// If category is not saved to the savedInstanceState,
// 0 is returned by default.
if(savedInstanceState != null) {
int category = savedInstanceState.getInt("category");
bar.selectTab(bar.getTabAt(category));
}
}
private void addActionBarBackArrow() {
if (android.os.Build.VERSION.SDK_INT >= 11) {
ActionBar bar = getActionBar();
if (bar != null) {
bar.setDisplayShowHomeEnabled(true);
bar.setDisplayHomeAsUpEnabled(true);
}
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectActivityLeaks()
.penaltyLog().build());
super.onCreate(savedInstanceState);
if(savedInstanceState != null && savedInstanceState.getInt("theme", -1) != -1) {
mThemeId = savedInstanceState.getInt("theme");
this.setTheme(mThemeId);
}
setContentView(R.layout.main);
Directory.initializeDirectory(new OnDirectoryChanged());
ActionBar bar = getActionBar();
int i;
for (i = 0; i < Directory.getCategoryCount(); i++) {
bar.addTab(bar.newTab().setText(Directory.getCategory(i).getName())
.setTabListener(this));
}
mActionBarView = getLayoutInflater().inflate(
R.layout.action_bar_custom, null);
bar.setCustomView(mActionBarView);
bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayShowHomeEnabled(true);
// If category is not saved to the savedInstanceState,
// 0 is returned by default.
if(savedInstanceState != null) {
int category = savedInstanceState.getInt("category");
bar.selectTab(bar.getTabAt(category));
}
}