android - requestWindowFeature(Window.FEATURE_NO_TITLE) exception

℡╲_俬逩灬. 提交于 2019-11-29 16:10:14

So:

@Override
protected void onCreate(
    final Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    // Make this activity, full screen
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // Hide the Title bar of this activity screen
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.main);

    // MORE INIT STUFF HERE...
    //img = (ImageView) findViewById(R.id.imgRandom);
    //btnRandom = (Button) findViewById(R.id.btnRandom);
}

it's so simple ... I just need to hide the ActionBar... then show it when back to standard screen...

   private void showStopButton(){
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        ActionBar actionBar = getActionBar();
        actionBar.hide();
        getWindow().findViewById(android.R.id.content).requestLayout();

Use -public class MainActivity extends Activity- instead of -public class MainActivity extends ActionBarActivity-

M.S

Try this one......

public class MainActivity extends Activity {

    Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        context = this;

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_main);
    }
}
Pavan jinka

Add this.

requestWindowFeature(Window.FEATURE_NO_TITLE);

before

 super.onCreate(savedInstanceState);
 setContentView(R.layout.your activity);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!