我有一个片段布局,也有一个ListView
。我使用定制ArrayAdapter
填充此ListView
。现在,如果我插入更多项目,我无法滚动此列表。如何插入滚动条到列表视图?
所以我想知道如何插入一个垂直滚动条到ListView。
这是布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="800dp"
android:layout_height="fill_parent" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="830dp"
android:layout_height="fill_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<LinearLayout
android:id="@+id/layoutText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_below="@id/layoutDate">
<View
android:layout_width="wrap_content"
android:layout_height="2dp"
android:background="@color/green"
android:layout_marginTop="15dp"/>
<!--LIST OF AGENT-->
<LinearLayout
android:id="@+id/layoutAgent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_below="@id/layoutDate">
<TextView
android:id="@+id/labelListAgent"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:gravity="left|center"
android:paddingLeft="15dp"
android:paddingTop="15dp"
android:text="@string/agent"/>
<ListView
android:id="@+id/listOfAgent"
android:layout_width="240dp"
android:layout_height="120dp"
android:scrollbars="vertical"
android:layout_gravity="fill_vertical"
android:layout_alignParentTop="true">
</ListView>
</LinearLayout>
<TextView android:id="@+id/labelAgent"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:gravity="left|center"
android:paddingLeft="15dp"
android:hint="Insert agent"
android:clickable="true"
/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
如果您阅读我的代码,此代码已存在 – bircastri
我已尝试编写wrap_content而不是120dp但问题是相同 – bircastri
ScrollView有什么特别的原因吗? – NezSpencer