goback add

Android新手入门教程(三):理解Activityの隐藏标题栏

3578 点击·0 回帖
灯火互联
楼主


如果愿意的话,我们可以把Activity的标题栏给隐藏了。如果想这么干的话,只需使用requestWindowFeature()方法,并传递Window.FEATURE_NO_TITLE常量值。
[java]
package net.learn2develop.Activity101;

import Android.app.Activity;
import Android.os.Bundle;
import Android.util.Log;
import Android.view.Window;

public class Activity101Activity extends Activity {
    String tag = "Lifecycle";

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // ---hides the title bar---  
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.main);
        Log.d(tag, "In the onCreate() event");
    }
}  
package net.learn2develop.Activity101;
import Android.app.Activity;
import Android.os.Bundle;
import Android.util.Log;
import Android.view.Window;
public class Activity101Activity extends Activity {
    String tag = "Lifecycle";
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // ---hides the title bar---
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);
        Log.d(tag, "In the onCreate() event");
    }
}
效果图:





喜欢0 评分0