【问题标题】:requestWindowFeature(Window.FEATURE_NO_TITLE); causing the App to crash?requestWindowFeature(Window.FEATURE_NO_TITLE);导致应用程序崩溃?
【发布时间】:2012-03-16 12:19:26
【问题描述】:

添加此行时应用程序崩溃

`requestWindowFeature(Window.FEATURE_NO_TITLE);

可能解决方法很简单,但我真的不知道该找谁解决。

Java 代码:

public class GLSurfaceCameraSurfaceDemo2Activity extends Activity {
/** Called when the activity is first created. */

GLSurfaceView glSurfaceView;
FrameLayout fl01;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

}

}

XML 文件:

<FrameLayout 
        android:id="@+id/fl01" 
        android:orientation="horizontal" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"/>  

【问题讨论】:

  • 你必须调用 requestWindowFeature(Window.FEATURE_NO_TITLE);在 setContentView() 之前。

标签: android android-framelayout


【解决方案1】:

你必须调用 requestWindowFeature(Window.FEATURE_NO_TITLE);在 setContentView() 之前...

public class GLSurfaceCameraSurfaceDemo2Activity extends Activity {
/** Called when the activity is first created. */

GLSurfaceView glSurfaceView;
FrameLayout fl01;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.main);

}

【讨论】:

    【解决方案2】:

    只要这样做:

    @Override
    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
    
        setContentView(R.layout.main);
    
    }
    

    你必须在super.onCreate(savedInstanceState);之前声明requestWindowFeature(Window.FEATURE_NO_TITLE);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-21
      • 2016-06-04
      • 2011-08-24
      • 2014-05-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多