I am using Java for an android project, since i have to use the application in full screen mode, when i pressed the drop down menu (spinner), full screen mode is disabled. do you have any options to prevent this? even i press the drop down, i don't want to exit the full screen. i have went through all the options including
//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) {
}
});
Here is the solution, put this method in your code and call the method onCreate after adding data to spinner.
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();
}
}