无法在AlertDialog /隐藏的LoginDialog导航栏 [英] Unable To Hide Navigation Bar during AlertDialog/LoginDialog

查看:2957
本文介绍了无法在AlertDialog /隐藏的LoginDialog导航栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过运行Android 4.2.2我的应用程序在全球隐藏导航栏

我已成功地使用实施以下(admitadly的hackish)方法:

  getWindow()getDecorView()setSystemUiVisibility(8);

其中成功地消除了导航栏(事实上,它是hackish的是完全没有问题 - 这是一个售货亭所以它将仅仅在设备上的有限数量的被安装)

现在我试图删除导航栏比我MainActivity其他地方 - 比如当它AlertDialog /时的LoginDialog再次出现

我试图使用方法:

 公共对话框onCreateDialog(捆绑savedInstanceState){
    AlertDialog.Builder建设者=新AlertDialog.Builder(新ContextThemeWrapper(getActivity(),R.style.HoloDarkDialog));
    LayoutInflater吹气= getActivity()getLayoutInflater()。    变量= SingletonVariables.getInstance();    鉴于= inflater.inflate(R.layout.login,NULL);
    的EditText userEditText =(EditText上)view.findViewById(R.id.loginUserIdEditText);
    。getWindow()getDecorView()setSystemUiVisibility(8)。

不过这个结果在错误:

 的方法getWindow()是未定义的类型函数LoginDialog

有谁知道这可能是可以避免的方法?

由于提前,

A.A。

编辑:(附加要求源$ C ​​$ C)

  //函数来处理显示对话框
公共无效showLogin(查看视图,弦乐whichActivity){
    PD =新ProgressDialog(this.getApplicationContext());
    pd.setMessage(登录,请稍候....);    一个LoginDialog =的LoginDialog新一个LoginDialog();
    logindialog.setWhichActivity(whichActivity);
    logindialog.show(getFragmentManager(),MyLogin);
}


解决方案

也许这可以帮助你?
<一href=\"http://stackoverflow.com/a/23435922/3464293\">http://stackoverflow.com/a/23435922/3464293

Smthng这样?

 查看decorView = getActivity()getWindow()getDecorView()。
INT uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

更新:
(来源:<一个href=\"http://stackoverflow.com/a/2844648/3464293\">http://stackoverflow.com/a/2844648/3464293)

在您LoginDialog.java添加这个方法:

  @覆盖
公共无效调用onStart(){
super.onStart();
窗口窗口= getDialog()getWindow()。
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.requestWindowFeature(Window.FEATURE_NO_TITLE);
INT uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
。window.getDecorView()setSystemUiVisibility(uiOptions);
}

和尝试呢。删除previous更新。

I'm attempting to hide the navigation bar globally through my app running Android 4.2.2

I have managed to use the following (admitadly hackish) method of implementing:

getWindow().getDecorView().setSystemUiVisibility(8);

Which successfully removes the Navigation bar (the fact it is hackish is perfectly fine - this is for a kiosk so it will only be installed on a limited number of devices)

Now I'm attempting to remove the navigation bar in places other than my MainActivity - such as when it reappears during a AlertDialog/LoginDialog.

I'm attempting to use:

public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(),R.style.HoloDarkDialog));
    LayoutInflater inflater = getActivity().getLayoutInflater();

    variables = SingletonVariables.getInstance();

    view = inflater.inflate(R.layout.login, null);
    EditText userEditText = (EditText) view.findViewById(R.id.loginUserIdEditText);
    getWindow().getDecorView().setSystemUiVisibility(8);

However this result in the error:

The method getWindow() is undefined for the type LoginDialog

Does anyone know of a way this might be avoided?

Thanks in advance,

A.A.

Edit: (additional requested source code)

// Function to handle show dialog
public void showLogin(View view, String whichActivity) {
    pd = new ProgressDialog(this.getApplicationContext());
    pd.setMessage("Logging in, Please wait....");

    LoginDialog logindialog = new LoginDialog();
    logindialog.setWhichActivity(whichActivity);
    logindialog.show(getFragmentManager(), "MyLogin");
}

解决方案

Maybe this can help you? http://stackoverflow.com/a/23435922/3464293

Smthng like this?

View decorView = getActivity().getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

Update: (source: http://stackoverflow.com/a/2844648/3464293)

In your LoginDialog.java add this method:

@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.requestWindowFeature(Window.FEATURE_NO_TITLE); 
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; 
window.getDecorView().setSystemUiVisibility(uiOptions);
}

and try then. Remove previous updates.

这篇关于无法在AlertDialog /隐藏的LoginDialog导航栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆