質問

い活動を取り扱うになります。今はこんなものがあるようで変更 レイアウト。また、onConfigurationChangedコールバック関数で設定を再度レイアウト、いまのレイアウト(土)いますが、それはまだ不明 最初のレイアウトのための画像ビューがレイアウト(名称)を設置res/ レイアウトおよびres/レイアウト-土地)

を削除するとandroid:configChanges="方位"を動作させることができるべきでıを取り扱う必要がありonConfigurationChanged.どうしたらよいですか??

役に立ちましたか?

解決

あなたはmain.xml/res/layoutであなたの肖像画のレイアウトmain.xmlとあなたのランドスケープレイアウト/res/layout-landを持っており、このようなあなたのonConfigurationChanged()のルックス場合:

    public void onConfigurationChanged(Configuration newConfig) {
            super.onConfigurationChanged(newConfig);                
            setContentView(R.layout.main);
    ...
    ...
    ...

    }

そして、あなたのマニフェストにあなたがandroid:configChanges="keyboardHidden|orientation"

が必要です これは私のアプリの場合と同様、

それから、罰金を動作するはずです。これは、あなたがやっているのですか?

他のヒント

// In your activity code.
int mCurrentOrientation;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mfo_offers);
    ........
    mCurrentOrientation = getCurrentOrientation();
}
@Override    
public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        // You may handle different configuration changes in your activity which configured in your mainfest.xml, you only need to recreate layout when orientation changes.
        if(mCurrentOrientation != newConfig.orientation) {          
            recreate(); // This recreate the activity if you can properly restore your activity state.  
        }
        ......
}
ここで

を参照してくださいActivity.recreate():ます。http:// developer.android.com/reference/android/app/Activity.html#recreate()

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top