2012-03-16 266 views
1

當我添加此行時,應用程序崩潰requestWindowFeature(Window.FEATURE_NO_TITLE);導致應用程序崩潰?

`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"/> 
+0

declar requestWindowFeature(Window.FEATURE_NO_TITLE);必須調用requestWindowFeature(Window.FEATURE_NO_TITLE);在setContentView()之前。 – 2012-03-16 12:22:51

回答

12

必須調用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); 

} 
+0

哦,我還沒有想過.....現在感謝它的工作 – LetsamrIt 2012-03-16 12:23:04

1

只是這樣做之前:

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

    setContentView(R.layout.main); 

} 

必須前super.onCreate(savedInstanceState);