テーブル行にボタンを動的に追加しようとしていますが、画面の向きに基づいてボタンのスタイルを変更する必要があります。私は、次の "game_answer_button.xml"レイアウトファイルを "layout"と "layout-land"の両方のフォルダに持っています。LayoutInflater経由でランドスケープリソースが選択されない
RES /レイアウト:
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/>
のres /レイアウト-土地:次のようにボタンレイアウトが私の活動に膨張している
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
style="@android:style/Widget.Button.Small"
/>
:
LayoutInflater inflater = getLayoutInflater();
Button button = (Button)inflater.inflate(R.layout.game_answer_button, null);
button.setText(image.getDescription());
しかし、それは既定の(ポートレート)レイアウトが毎回選択されます。デフォルトレイアウトの内容がランドスケープレイアウトに置き換えられた場合、ランドスケープレイアウトが最後にレンダリングされます。 LayoutInflater経由でランドスケープレイアウトリソースを正しく選択しているようには見えません。
これに関するご意見はありますか?
はい、私はマニフェストでアクティビティに特定の方向属性が設定されていないことを確認しました。 –