- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一款使用 AndEngine 的游戏。
AndEngine 有一个“BaseGameActivity”,Google Play 游戏服务也有。我不得不将 BaseGameActivity 从 AndEngine 重命名为 AEBaseGameActivity,并将其作为父类 BaseGameActivity 而不是 Activity。
但它给我这个错误:
Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:226)
at org.andengine.util.ActivityUtils.requestFullscreen(ActivityUtils.java:56)
at org.andengine.ui.activity.AEBaseGameActivity.applyEngineOptions(AEBaseGameActivity.java:427)
at org.andengine.ui.activity.AEBaseGameActivity.onCreate(AEBaseGameActivity.java:83)
现在AndEngine有这段代码:
public static void requestFullscreen(final Activity pActivity) {
final Window window = pActivity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
window.requestFeature(Window.FEATURE_NO_TITLE);
}
如果我评论 requestFeature 行,我的项目就会运行!但是它有一个难看的标题栏。
请问有人知道解决这个问题的方法吗?
编辑,这里是一些更多的代码:
PS: AEBaseGameActivity.php 扩展了 BaseActivity,它扩展了 BaseGameActivity(以前只是 Activity )
AEBaseGameActivity.php
public abstract class AEBaseGameActivity extends BaseActivity implements IGameInterface, IRendererListener {
@Override
protected void onCreate(final Bundle pSavedInstanceState) {
if(BuildConfig.DEBUG) {
Debug.d(this.getClass().getSimpleName() + ".onCreate" + " @(Thread: '" + Thread.currentThread().getName() + "')");
}
super.onCreate(pSavedInstanceState);
this.mGamePaused = true;
this.mEngine = this.onCreateEngine(this.onCreateEngineOptions());
this.mEngine.startUpdateThread();
this.applyEngineOptions(); //REQUEST FULLSCREEN
this.onSetContentView(); //SET CONTENT VIEW
}
...
private void applyEngineOptions() {
final EngineOptions engineOptions = this.mEngine.getEngineOptions();
if(engineOptions.isFullscreen()) {
ActivityUtils.requestFullscreen(this); //ACTIVITY UTIL SHOWN LATER
}
...
}
...
protected void onSetContentView() {
this.mRenderSurfaceView = new RenderSurfaceView(this);
this.mRenderSurfaceView.setRenderer(this.mEngine, this);
this.setContentView(this.mRenderSurfaceView, AEBaseGameActivity.createSurfaceViewLayoutParams());
}
}
ActivityUtils.java
public class ActivityUtils {
public static void requestFullscreen(final Activity pActivity) {
final Window window = pActivity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
window.requestFeature(Window.FEATURE_NO_TITLE); //IF COMMENTING THIS, THE GAME IS RUNNING
}
...
}
编辑2:
代码基本只有AndEngine,这里是原代码:
https://github.com/nicolasgramlich/AndEngine/tree/GLES2/src/org/andengine/ui/activity
我的改变:
最佳答案
好的,这就是我所做的:
我在 Android Manifest 的 Activity 中添加了这个:
android:theme="@android:style/Theme.NoTitleBar"
它最终看起来像这样:
<activity
android:name=".GameActivity"
android:theme="@android:style/Theme.NoTitleBar"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
关于java - requestFeature() before adding content error when trying to make AndEngine work with Google Play Game Service,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17930196/
所以我在看谷歌的操作栏 API 演示,他们有这个 // The Action Bar is a window feature. The feature must be requested //
我正在尝试实现自定义标题栏: 这是我的 Helper 类: import android.app.Activity; import android.view.Window; public class
我目前正在尝试弹出一个 AlertDialog 框,其中包含有关具有自定义布局文件“details.xml”的电影的信息我觉得这可能是我填充这些字段的方式,但我不确定如何最好地处理它。 listVie
首先让我道歉,这是一个带有代码墙的长帖子,但我想要彻底。 当我单击按钮在我的程序中启动此 fragment 时,我的logcat 中出现错误。它声明我必须“在添加内容之前请求特征 ()”。我已经用尽了
编辑反射(reflect)matias的评论 实际上,最初我的代码中没有supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRES
android.util.AndroidRuntimeException: requestFeature() must be called before adding content 我在使用时遇到这
我正在使用 xamarin 表单开发一个示例登录应用程序,我在常见的可移植项目中开发了代码。在Xamarin forms android项目中运行时,报错: Android.Util.AndroidR
我想在使用 setContentView() 加载 View 后调用 requestFeature(),但错误非常明显: android.util.AndroidRuntimeException: r
我在尝试在我的 FRAGMENT 中使用“requestFeature”时遇到问题。我的代码在下面,我正在尝试将操作栏设置为覆盖。 @Override public void onCreate
这个问题在这里已经有了答案: requestFeature() must be called before adding content (9 个回答) 关闭 8 年前。 我有对话 fragment
我有一个扩展 ActionBarActivity 的抽象类。在 onCreate 中,我有: @Override protected void onCreate(Bundle savedInstanc
这个问题已经有答案了: requestFeature() must be called before adding content (9 个回答) 已关闭 8 年前。 Android Eclipse
我使用主详细信息模板启动了一个新应用。 当我在我的平板电脑上试用该应用程序时,使用双 Pane 布局,当我改变平板电脑的方向时,它会崩溃,标题中出现异常。仅当详细信息 fragment 有内容时才会发
我知道这个问题已经在这里问了很多次,但在花了最后 1.5 小时阅读并试图解决我的问题后,我不能。 问题陈述: 在 DialogFragment 中调用 setStyle 方法时,出现标题中所述的 Ru
我正在创建一个包含 EditText 的自定义对话框,以便我可以从用户那里获取文本数据: final EditText newKey = (EditText) findViewById(R.id.di
首先,这不是我自己遇到的问题。点击测试广告在我的所有设备上都能正常工作。但是,我收到了一些用户(不使用 root 或 Xposed)的崩溃报告。 Exception java.lang.Runtime
当我想在我的操作栏上添加一个应用程序图标时遇到了一些问题。 所以我有 ActionBarActivity 类,它在 onCreate() 中有以下代码 @Override protected void
我知道过去有人问过类似的问题,但即使有这些建议,我似乎也根本无法解决这个问题。 我在“show()”命令上得到上述异常终止。 public void onCreate(Bundle savedInst
所以我想将自定义 ImageView 添加到 ProgressDialog: LinearLayout root = (LinearLayout)findViewById(R.id.root); Pr
我收到此 android.util.AndroidRuntimeException: requestFeature() must be called before added content 错误。正
我是一名优秀的程序员,十分优秀!