ユーザがedittextフィールドにデータを入れて向きを変更すると、onConfigChangeメソッドが呼び出され、空のedittextフィールドを持つ新しいレイアウトが設定されます。ユーザがオリエンテーションを変更することによって入力されたedittextフィールドのデータ。 どんな種類のヘルプも高く評価されます。save onConfigChange()を実装しているときの向き変更に関する以前のレイアウトのデータ
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int orientation_default = getResources().getConfiguration().orientation;
switch (orientation_default) {
case Configuration.ORIENTATION_PORTRAIT: {
setContentView(R.layout.registration);
break;
}
case Configuration.ORIENTATION_LANDSCAPE: {
setContentView(R.layout.registration_horizontal);
break;
}
}
findViewById(R.id.backtohomepage).setOnClickListener(this);
findViewById(R.id.backtologinpage).setOnClickListener(this);
findViewById(R.id.btn_notregyetsubmit).setOnClickListener(this);
findViewById(R.id.termsandconditions_id).setOnClickListener(this);
findViewById(R.id.btn_notregyetsubmit).setOnClickListener(this);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
setContentView(R.layout.registration);
findViewById(R.id.termsandconditions_id).setOnClickListener(this);
findViewById(R.id.backtohomepage).setOnClickListener(this);
findViewById(R.id.backtologinpage).setOnClickListener(this);
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
setContentView(R.layout.registration_horizontal);
}
findViewById(R.id.backtologinpage).setOnClickListener(this);
findViewById(R.id.btn_notregyetsubmit).setOnClickListener(this);
findViewById(R.id.termsandconditions_id).setOnClickListener(this);
findViewById(R.id.btn_notregyetsubmit).setOnClickListener(this);
};