gpt4 book ai didi

java - 当按下微调器下拉按钮时,全屏模式被禁用

转载 作者:行者123 更新时间:2023-12-02 00:57:06 24 4
gpt4 key购买 nike

我正在将 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) {

}

});

最佳答案

这是解决方案,将此方法放入您的代码中,并在向 Spinner 添加数据后调用 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();
}
}

关于java - 当按下微调器下拉按钮时,全屏模式被禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57807405/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com