0

事前定義された属性を使用して View オブジェクトを作成するベスト プラクティスは何ですか?

次のようなものを使いたい

View view = (View) inflater.inflate(R.layout.orangeview, container,
                false);

しかし、オレンジ色のビューがビュー グループ内にある必要があるようで、レイアウト ファイル内にもっとスタンドアロンのものを用意したいと思います - 次のような唯一のビュー属性

<?xml version="1.0" encoding="utf-8"?>
<RadioButton
    android:layout_width="fill_parent"
    android:id="@+id/orangeradiobutton"
    android:layout_weight="1"
    android:button="@null"
    android:gravity="center"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="@color/radiobutton_colors" />

それは可能ですか、それとも別のアプローチを使用する必要がありますか?

4

1 に答える 1

0

コンテナ引数は、膨張したレイアウトの「サイズ」に使用されます。これが不要な場合は、電話するだけです

View view = inflater.inflate(R.layout.orangeView, null);
于 2012-07-16T20:23:19.797 に答える