本文整理了Java中android.view.Window.hasFeature()
方法的一些代码示例,展示了Window.hasFeature()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.hasFeature()
方法的具体详情如下:
包路径:android.view.Window
类名称:Window
方法名:hasFeature
暂无
代码示例来源:origin: novoda/android-demos
private void initialize(Window window, Context context) {
View decor = window.getDecorView();
ViewGroup group = (ViewGroup) window.getDecorView();
LayoutInflater inflater = (LayoutInflater) decor.getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.lib_title_container, group, true);
inflater.inflate(R.layout.lib_left_nav, group, true);
mContext = decor.getContext();
mIsOverlay = window.hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
mTitleBar = (TitleBarView) decor.findViewById(R.id.title_container);
mLeftNav = (LeftNavView) decor.findViewById(R.id.left_nav);
mContent = group.getChildAt(0);
if (mTitleBar == null || mLeftNav == null) {
throw new IllegalStateException(
getClass().getSimpleName() + ": incompatible window decor!");
}
setDisplayOptions(DEFAULT_DISPLAY_OPTIONS);
showOptionsMenu(true);
}
代码示例来源:origin: square/assertj-android
@TargetApi(HONEYCOMB)
public WindowAssert hasFeature(@WindowFeature int feature) {
isNotNull();
//noinspection ResourceType
assertThat(actual.hasFeature(feature)) //
.overridingErrorMessage("Expected feature <%s> but was not present.",
featureToString(feature)) //
.isTrue();
return this;
}
代码示例来源:origin: com.actionbarsherlock/actionbarsherlock
@Override
public boolean hasFeature(int feature) {
if (ActionBarSherlock.DEBUG) Log.d(TAG, "[hasFeature] feature: " + feature);
final boolean result = mActivity.getWindow().hasFeature(feature);
if (ActionBarSherlock.DEBUG) Log.d(TAG, "[hasFeature] returning " + result);
return result;
}
代码示例来源:origin: com.willowtreeapps/oak-demos
@Override
public boolean hasFeature(int feature) {
if (DEBUG) Log.d(TAG, "[hasFeature] feature: " + feature);
final boolean result = mActivity.getWindow().hasFeature(feature);
if (DEBUG) Log.d(TAG, "[hasFeature] returning " + result);
return result;
}
代码示例来源:origin: de.keyboardsurfer.android.widget/crouton
@TargetApi(11)
private void handleActionBarOverlay(ViewGroup.MarginLayoutParams params, Activity activity) {
// ActionBar overlay is only available as of Android 3.0 Honeycomb.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
final boolean flags = activity.getWindow().hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
if (flags) {
setActionBarMargin(params, activity);
}
}
}
代码示例来源:origin: stackoverflow.com
private void initWindowDecorActionBar() {
Window window = getWindow();
// Initializing the window decor can change window feature flags.
// Make sure that we have the correct set before performing the test below.
window.getDecorView();
if (isChild() || !window.hasFeature(Window.FEATURE_ACTION_BAR) || mActionBar != null) {
return;
}
mActionBar = new WindowDecorActionBar(this);
mActionBar.setDefaultDisplayHomeAsUpEnabled(mEnableDefaultActionBarUp);
mWindow.setDefaultIcon(mActivityInfo.getIconResource());
mWindow.setDefaultLogo(mActivityInfo.getLogoResource());
}
代码示例来源:origin: stackoverflow.com
boolean hasFeature(int feature) {
Window window = getWindow(); //get the window instance.
if (android.os.Build.VERSION.SDK_INT >= 11) { // if we are running api level 11 and later
return window.hasFeature(feature); //call hasFeature
} else {
try {
Class c = window.getClass();
Method getFeatures = c.getDeclaredMethod("getFeatures");//get the getFeatures method using reflection
getFeatures.setAccessible(true);//make it public
Integer features = getFeatures.invoke(window, null); //invoke it
return (features.intValue() & (1 << feature)) != 0; //check if we have the feature and return the result.
} catch (Exception e) {
return false;//in case invocation fails with any reason
}
}
}
代码示例来源:origin: com.squareup.assertj/assertj-android
@TargetApi(HONEYCOMB)
public WindowAssert hasFeature(@WindowFeature int feature) {
isNotNull();
//noinspection ResourceType
assertThat(actual.hasFeature(feature)) //
.overridingErrorMessage("Expected feature <%s> but was not present.",
featureToString(feature)) //
.isTrue();
return this;
}
代码示例来源:origin: nekocode/JarFilterPlugin
@Override
public void openOptionsMenu() {
ActionBar actionBar = getSupportActionBar();
if (getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)
&& (actionBar == null || !actionBar.openOptionsMenu())) {
super.openOptionsMenu();
}
}
代码示例来源:origin: nekocode/JarFilterPlugin
@Override
public void closeOptionsMenu() {
ActionBar actionBar = getSupportActionBar();
if (getWindow().hasFeature(Window.FEATURE_OPTIONS_PANEL)
&& (actionBar == null || !actionBar.closeOptionsMenu())) {
super.closeOptionsMenu();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!