私は約 60 個のフラグメントを持っています " ListFragment
"。今では、このように同じレイアウト ファイル内の別のフラグメントで各 Listfragment を使用しています。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/carDetailedFragment"
android:name="com.ui.fragment.CarDetailedFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<fragment
android:id="@+id/carcategorylistfragment"
android:name="com.ui.fragment.CarCategoryListFragment"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
問題は、フラグメントごとに 60 個のレイアウト ファイルを作成する必要があるか、または 2 つのフラグメントを含むテンプル レイアウトを作成し、それらのクラスを設定できるかということです。
android:name
ビューexの属性を設定するようなインフレ時の属性
setContentView(R.layout.somelayout);
View v = findViewById(R.id.src);
v.setVisibility(View.GONE);