有没有方法可以为列表查看设置可查看项目数量?还是我有义务设置listview的高度?在列表视图中设置可查看项目数量
例如,我收到了一个包含9个项目的列表。我只想要其中4人首先出现。然后用户需要滚动查看其他项目。
list_anlam.xml
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="1dp"
android:background="@android:color/darker_gray" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/title_popup_hikayeoku" />
<EditText android:id="@+id/kelime_text"
android:inputType="text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ListView android:id="@+id/list_anlam"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<Button
android:id="@+id/button_sec"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/button_popup_hikayeoku" />
</LinearLayout>
list_item.xml:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="20sp"
android:padding="10dp" />
哪里填充物品放入列表视图:HikayeOkuActivity.java是
String[] anlamlar = null;
anlamlar = MainActivity.dbM.ilkAnlamGetir(selectedText);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item,anlamlar);
anlamList.setAdapter(adapter);
popupWindow.showAsDropDown(mainLayout, touchedX,touchedY);
有一个默认设置,你可以设置和一个最大尺寸...之后,应该自动启用滚动条 – StackFlowed 2014-09-02 13:16:01
@Aeshang我到底在哪里可以设置这些默认设置? – rentire 2014-09-02 13:28:13
list.setBounds(,,,);在Java SWT ...你在用什么? – StackFlowed 2014-09-02 13:40:45