有沒有方法可以爲列表查看設置可查看項目數量?還是我有義務設置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