【问题标题】:when pressed the spinner drop down, full screen mode disabled按下微调器下拉菜单时,禁用全屏模式
【发布时间】:2019-09-05 14:11:44
【问题描述】:

我将 Java 用于 android 项目,因为我必须在全屏模式下使用应用程序,当我按下下拉菜单(微调器)时,全屏模式被禁用。你有什么办法可以防止这种情况发生吗?即使我按下下拉菜单,我也不想退出全屏。 我已经完成了所有选项,包括

//method for full screen
private void hideSystemUI() {

    View decorView = getWindow().getDecorView();
    decorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_IMMERSIVE

                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN);
}

  ArrayAdapter<String> adapter = new ArrayAdapter<String>(Main_Menu.this,
                R.layout.custom_spinner, paths);

        adapter.setDropDownViewResource(R.layout.custom_spinner_drop_down_item);
        btnlanguage.setAdapter(adapter);


        btnlanguage.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {

                //   Toast.makeText(Main_Menu.this, urlinformation.HomeURL(btnlanguage.getSelectedItem().toString(), slug), Toast.LENGTH_LONG).show();
                mywebview.loadUrl(urlinformation.HomeURL(btnlanguage.getSelectedItem().toString(), slug));

            }

            @Override
            public void onNothingSelected(AdapterView<?> parentView) {

            }

        });

【问题讨论】:

    标签: java android android-spinner


    【解决方案1】:

    这里是解决方法,把这个方法放在你的代码中,在给微调器添加数据后调用onCreate方法。

       public static void apply(Spinner spinner) {
        try {
            Field listPopupField = Spinner.class.getDeclaredField("mPopup");
            listPopupField.setAccessible(true);
            Object listPopup = listPopupField.get(spinner);
            if (listPopup instanceof ListPopupWindow) {
                Field popupField = ListPopupWindow.class.getDeclaredField("mPopup");
                popupField.setAccessible(true);
                Object popup = popupField.get((ListPopupWindow) listPopup);
                if (popup instanceof PopupWindow) {
                    ((PopupWindow) popup).setFocusable(false);
                }
            }
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-18
      • 1970-01-01
      相关资源
      最近更新 更多