SSブログ

画面の向きを固定する [画面]

ManifestファイルのActivityの要素にandroid:screenOrientationで設定する。

    <application android:icon="@drawable/icon" 
android:label="@string/app_name" 
android:debuggable="true">
        <activity android:name=".MainActivity" 
android:label="@string/app_name" 
android:screenOrientation="landscape">


 
http://developer.android.com/intl/ja/guide/topics/manifest/activity-element.html#screen
 



戻るボタンを制御する [ボタン]

戻るボタンを強制的に制御できる。

    public boolean dispatchKeyEvent(KeyEvent e) {
        if (e.getKeyCode() == KeyEvent.KEYCODE_BACK) {
            //ここで制御したい処理を書く。
            if (e.getAction() == KeyEvent.ACTION_DOWN) {
                return false;
            }

            return true;
        }
        return super.dispatchKeyEvent(e);
    }




見れば分かるが、何も戻るボタンに限った話ではない。







タグ:ボタン

この広告は前回の更新から一定期間経過したブログに表示されています。更新すると自動で解除されます。