Android:无法隐藏状态栏

小卒过河 发布于 2011/07/18 15:10
阅读 2K+
收藏 1

我想在Android 3.1 中隐藏状态栏,当用户触摸屏幕时,状态栏再出现,2S后又隐藏。

下面是我的代码:

private static ViewFlipper flipper = null;

private static ImageView ivScreenSnapshot = null;

public static AbsoluteLayout managerField = null;

public void onCreate(Bundle savedInstanceState)

{

    super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);


managerField = new AbsoluteLayout(this);

flipper = new ViewFlipper(this)
{  
    @Override
    public boolean onTouchEvent(MotionEvent event) 
    {

        flipper.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
        Thread t = new Thread()
        {
            public void run()
            {
                try {
                sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            Global.handler.post(new Runnable()
            {
                public void run()
                {
                    flipper.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
                }
            });
            }
        };
        t.start();
        return super.onTouchEvent(event);
    }
};
ivScreenSnapshot = new ImageView(this);
flipper.addView(managerField);
flipper.addView(ivScreenSnapshot);
setContentView(flipper);
flipper.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);

} 
程序不灵,状态栏依然可见。有什么好建议吗?谢谢。
加载中
0
韭精过敏
韭精过敏
去看看文档的详细介绍,是不是你方法的问题
返回顶部
顶部