Wie man onConfigurationChanged () und newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE in Android 2.3.3 verwendet

Ich bin mit onConfigurationChanged(). In, dass, wenn ich den Wechsel von quer-auf Hochformat, es ruft if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) und die Verlagerung Portrait vor Landschaft. Aber wenn ich die Wechsel von hoch-ins Querformat, es ist nicht zu ändern, um die Landschaft, denn es ruft if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) so, es ist nicht zu ändern, von quer-auf Hochformat.
Bitte helfen Sie.

public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        //int orientation = this.getResources().getConfiguration().orientation;

        if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
            Log.d("Entered to change as Portrait ","PPPPPPPPPPPPPPPPP");
            setContentView(R.layout.settings);
        } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            Log.d("Entered to change as LandScape ","LLLLLLLLLLLLLLLLLLLL");
            setContentView(R.layout.settings);
        }

    }

InformationsquelleAutor der Frage Rajesh | 2012-03-05

Schreibe einen Kommentar