以下のコードを参照してください。
私は、単一の ListView "lstv" を含むレイアウトを、コード内の LinearLayout コンテナー "llytFragmentContainer" に膨張させる Fragment を持っています。私が抱えている問題は、ListView がスクロールしないことです。おそらくレイアウトの設定方法に関係があることはわかっています。
Fragment でレイアウトを拡張するコード:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.frag, container, false);
}
フラグメントのレイアウト:
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/lstv"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
アクティビティのレイアウト:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="100" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:padding="10dp"
android:orientation="horizontal"
android:weightSum="100" >
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="88"
style="@android:style/Widget.ProgressBar.Horizontal" />
<TextView
android:id="@+id/txtProgress"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="12"
android:layout_marginLeft="10dp" />
</LinearLayout>
<TextView
android:id="@+id/txtCounter"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"
android:gravity="center_horizontal"
android:textSize="20dp" />
<LinearLayout
android:id="@+id/llytFragmentContainer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="67">
</LinearLayout>
<Button
android:id="@+id/btnEnd"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="15"
android:text="End Tour" />
</LinearLayout>