I use grid view in my application activity. Each row of the grid view contains three flags that can be set to selected / not selected based on what the user wants to query from the database. The activity also includes editText, which causes the onScreenKeyboard to appear every time the activity starts, and this is where the problem arises. OnScreenKeyboard, when an alarm grid appears, and some of its flags simply disappear. My idea was to update the grid every time a configuration change. I tried to handle this by returning an object via onRetainNonConfigurationInstance () . The object contains a list of arrays to populate my gridview lines, but onCreate () , when I use getLastNonConfigurationInstance () to retrieve the returned object, it shows null. Can someone please suggest me how to deal with this problem or if there is any other access with which I can make my gridView behave normally when changing the configuration. The code is below, and I want it to become clear. I added a keyboardHidden configuration change in the manifest file, but when the keyboard appears, onConfigurationChanged () sometimes fails
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.failureselection); findLocalWidgets(); //Initializes Layout Objects if(configchanged){ //Re populate grid view customDataGridRows = (ArrayList<CustomGridViewRow>) getLastNonConfigurationInstance(); dgvwFailures.setAdapter(new CustomGridViewAdapter(this, customDataGridRows)); configchanged = false; }else{ fillFailuresList(customDataGridRows); dgvwFailures.setAdapter(new CustomGridViewAdapter(this, customDataGridRows)); } } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); setContentView(R.layout.failureselection); configchanged = true; } @Override public Object onRetainNonConfigurationInstance() { return customDataGridRows; } private boolean fillFailuresList( ArrayList<CustomGridViewRow> customDataGridRows) { boolean isFilled = false; try { // Adding Failures data customDataGridRows.add(new CustomGridViewRow(false, "Hood", false, "Assembly Defect", false, "Masking Poor")); customDataGridRows.add(new CustomGridViewRow(false, "Floor", false, "Forget Work", false, "Assembly Defect")); customDataGridRows.add(new CustomGridViewRow(false, "Grill", false, "Incorrect Assembly", false, "Bad Company")); customDataGridRows.add(new CustomGridViewRow(false, "R Right Frame", false, "Interference", false, "Fix Large Effort")); customDataGridRows.add(new CustomGridViewRow(false, "R Left Frame", false, "Leakage", false, "High Incidence")); customDataGridRows.add(new CustomGridViewRow(false, "R Frame", false, "Dirt", false, "Recurrence")); customDataGridRows.add(new CustomGridViewRow(false, "Outside R Frame", false, "Decal", false, "Checking")); customDataGridRows.add(new CustomGridViewRow(false, "F Right Frame", false, "Other", false, "Foreign Body")); customDataGridRows.add(new CustomGridViewRow(false, "F Left Frame", false, "", false, "Not Caulking")); customDataGridRows.add(new CustomGridViewRow(false, "F Frame", false, "", false, "Painting Defect")); customDataGridRows.add(new CustomGridViewRow(false, "Outsie F Frame", false, "", false, "Other")); customDataGridRows.add(new CustomGridViewRow(false, "", false, "", false, "")); // Populating Failures grid view // dgvwFailures.setAdapter(new CustomGridViewAdapter(this, // customDataGridRows)); isFilled = true; } catch (Exception e) { e.getMessage(); } return isFilled; }