本文整理汇总了Java中android.app.ActionBar类的典型用法代码示例。如果您正苦于以下问题:Java ActionBar类的具体用法?Java ActionBar怎么用?Java ActionBar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionBar类属于android.app包,在下文中一共展示了ActionBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.app.ActionBar; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getActionBar();
if (null != actionBar) actionBar.hide();
ButterKnife.bind(this);
FirebaseAuth auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser() != null) {
showWhiteSnackBar(R.string.sign_in_successful);
googleLoginButton.setVisibility(View.INVISIBLE);
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
}
示例2: onCreate
import android.app.ActionBar; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(savedInstanceState != null) {
if (savedInstanceState.getInt("theme", -1) != -1) {
mThemeId = savedInstanceState.getInt("theme");
this.setTheme(mThemeId);
}
mTitlesHidden = savedInstanceState.getBoolean("titlesHidden");
}
setContentView(R.layout.main);
ActionBar bar = getActionBar();
bar.setDisplayShowTitleEnabled(false);
ContentFragment frag = (ContentFragment) getFragmentManager()
.findFragmentById(R.id.content_frag);
if (frag != null) mDualFragments = true;
if (mTitlesHidden) {
getFragmentManager().beginTransaction()
.hide(getFragmentManager().findFragmentById(R.id.titles_frag)).commit();
}
}
示例3: setActionBarDescription
import android.app.ActionBar; //导入依赖的package包/类
public static SetIndicatorInfo setActionBarDescription(SetIndicatorInfo info, Activity activity, int contentDescRes) {
if (info == null) {
info = new SetIndicatorInfo(activity);
}
if (info.setHomeAsUpIndicator != null) {
try {
ActionBar actionBar = activity.getActionBar();
info.setHomeActionContentDescription.invoke(actionBar, new Object[]{Integer.valueOf(contentDescRes)});
if (VERSION.SDK_INT <= 19) {
actionBar.setSubtitle(actionBar.getSubtitle());
}
} catch (Exception e) {
Log.w(TAG, "Couldn't set content description via JB-MR2 API", e);
}
}
return info;
}
示例4: onCreate
import android.app.ActionBar; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
this.setTheme(R.style.SettingsTheme);
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setIcon(R.drawable.null_icon);
if (InterfaceUtils.getTabletMode(this)) {
addPreferencesFromResource(R.xml.preferences_tab);
} else {
addPreferencesFromResource(R.xml.preferences);
}
}
示例5: setActionBarUpIndicator
import android.app.ActionBar; //导入依赖的package包/类
public static SetIndicatorInfo setActionBarUpIndicator(SetIndicatorInfo info, Activity activity, Drawable drawable, int contentDescRes) {
info = new SetIndicatorInfo(activity);
if (info.setHomeAsUpIndicator != null) {
try {
ActionBar actionBar = activity.getActionBar();
info.setHomeAsUpIndicator.invoke(actionBar, new Object[]{drawable});
info.setHomeActionContentDescription.invoke(actionBar, new Object[]{Integer.valueOf(contentDescRes)});
} catch (Exception e) {
Log.w(TAG, "Couldn't set home-as-up indicator via JB-MR2 API", e);
}
} else if (info.upIndicatorView != null) {
info.upIndicatorView.setImageDrawable(drawable);
} else {
Log.w(TAG, "Couldn't set home-as-up indicator");
}
return info;
}
示例6: onCreate
import android.app.ActionBar; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// FIXME: Observed exception "IllegalAccessException (@MainActivity:onCreate:16) {main}"
// Init some singletons which need the Context
Analytics.getInstance().init(this);
SettingsUtils.getInstance().init(this);
setContentView(R.layout.activity_main);
final ActionBar actionBar=getActionBar();
if (actionBar!=null) {
actionBar.setDisplayShowTitleEnabled(true);
//actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
}
final IntentFilter filter=new IntentFilter();
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
registerReceiver(usbReceiver,filter);
}
示例7: setActionBarUpIndicator
import android.app.ActionBar; //导入依赖的package包/类
public static void setActionBarUpIndicator(Object info, Activity activity, Drawable drawable, int contentDescRes) {
final SetIndicatorInfo sii = (SetIndicatorInfo) info;
if (sii.setHomeAsUpIndicator != null) {
try {
final ActionBar actionBar = activity.getActionBar();
sii.setHomeAsUpIndicator.invoke(actionBar, drawable);
sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
} catch (Throwable t) {
if (ActionBarHelper.DEBUG) Log.e(TAG, "Couldn't set home-as-up indicator via JB-MR2 API", t);
}
} else if (sii.upIndicatorView != null) {
sii.upIndicatorView.setImageDrawable(drawable);
} else {
if (ActionBarHelper.DEBUG) Log.e(TAG, "Couldn't set home-as-up indicator");
}
}
示例8: setActionBarDescription
import android.app.ActionBar; //导入依赖的package包/类
public static Object setActionBarDescription(Object info, Activity activity, int contentDescRes) {
SetIndicatorInfo setIndicatorInfo;
if (info == null) {
setIndicatorInfo = new SetIndicatorInfo(activity);
}
SetIndicatorInfo sii = setIndicatorInfo;
if (sii.setHomeAsUpIndicator != null) {
try {
ActionBar actionBar = activity.getActionBar();
sii.setHomeActionContentDescription.invoke(actionBar, new Object[]{Integer.valueOf(contentDescRes)});
if (VERSION.SDK_INT <= 19) {
actionBar.setSubtitle(actionBar.getSubtitle());
}
} catch (Exception e) {
Log.w(TAG, "Couldn't set content description via JB-MR2 API", e);
}
}
return setIndicatorInfo;
}
示例9: onCreate
import android.app.ActionBar; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getActionBar();
if (null != actionBar) actionBar.hide();
mBottomBar.setOnTabSelectListener(
new OnTabSelectListener() {
@Override
public void onTabSelected(@IdRes int tabId) {
Fragment fragment;
switch (tabId) {
case R.id.bot_bar_today:
fragment = new TodayTasksFragment();
break;
case R.id.bot_bar_list:
fragment = new ListTasksFragment();
break;
case R.id.bot_bar_more:
fragment = new MoreInfoFragment();
break;
default:
fragment = new TodayTasksFragment();
}
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.replace(R.id.flContent, fragment, fragment.getClass().getName());
ft.commit();
}
});
}
示例10: setActionBarDescription
import android.app.ActionBar; //导入依赖的package包/类
public static SetIndicatorInfo setActionBarDescription(SetIndicatorInfo info, Activity activity,
int contentDescRes) {
if (info == null) {
info = new SetIndicatorInfo(activity);
}
if (info.setHomeAsUpIndicator != null) {
try {
final ActionBar actionBar = activity.getActionBar();
info.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
if (Build.VERSION.SDK_INT <= 19) {
// For API 19 and earlier, we need to manually force the
// action bar to generate a new content description.
actionBar.setSubtitle(actionBar.getSubtitle());
}
} catch (Exception e) {
Log.w(TAG, "Couldn't set content description via JB-MR2 API", e);
}
}
return info;
}
示例11: onPreferenceTreeClick
import android.app.ActionBar; //导入依赖的package包/类
@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;
}
示例12: setActionBarUpIndicator
import android.app.ActionBar; //导入依赖的package包/类
public static Object setActionBarUpIndicator(Object info, Activity activity, Drawable drawable, int contentDescRes) {
SetIndicatorInfo setIndicatorInfo;
if (info == null) {
setIndicatorInfo = new SetIndicatorInfo(activity);
}
SetIndicatorInfo sii = setIndicatorInfo;
if (sii.setHomeAsUpIndicator != null) {
try {
ActionBar actionBar = activity.getActionBar();
sii.setHomeAsUpIndicator.invoke(actionBar, new Object[]{drawable});
sii.setHomeActionContentDescription.invoke(actionBar, new Object[]{Integer.valueOf(contentDescRes)});
} catch (Exception e) {
Log.w(TAG, "Couldn't set home-as-up indicator via JB-MR2 API", e);
}
} else if (sii.upIndicatorView != null) {
sii.upIndicatorView.setImageDrawable(drawable);
} else {
Log.w(TAG, "Couldn't set home-as-up indicator");
}
return setIndicatorInfo;
}
示例13: menuBarsHide
import android.app.ActionBar; //导入依赖的package包/类
private void menuBarsHide() {
Log.d(getClass().getName(), "menuBarsHide");
ActionBar actionBar = getActionBar();
if (actionBar == null) {
Log.d(getClass().getName(), "menuBarsHide ActionBar is null");
return;
}
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LOW_PROFILE);
actionBar.hide(); // slides out
}
示例14: makeDoneCancelLayout
import android.app.ActionBar; //导入依赖的package包/类
public static View makeDoneCancelLayout(int layoutId,
LayoutInflater layoutInflater,
int doneId,
View.OnClickListener onDoneListener,
int cancelId,
View.OnClickListener onCancelListener) {
@SuppressLint("InflateParams")
LinearLayout doneDiscardLayout = (LinearLayout) layoutInflater.inflate(layoutId,
null);
doneDiscardLayout.setLayoutParams(new ActionBar.LayoutParams(
ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT));
doneDiscardLayout.findViewById(doneId)
.setOnClickListener(onDoneListener);
doneDiscardLayout.findViewById(cancelId)
.setOnClickListener(onCancelListener);
return doneDiscardLayout;
}
示例15: setTitle
import android.app.ActionBar; //导入依赖的package包/类
public static void setTitle(android.support.v7.app.ActionBar actionBar, SpannableString spannableString) {
// BUGFIX
// @see http://stackoverflow.com/questions/7658725/android-java-lang-illegalargumentexception-invalid-payload-item-type
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN && Build.MANUFACTURER.toUpperCase().equals("LGE")) {
actionBar.setTitle(spannableString.toString());
} else {
actionBar.setTitle(spannableString);
}
}