I am trying to include a ListView
within an Activity
that is running inside a Dialog
. The dialog is basically used to search for bluetooth devices, so I need two Button
's, a TextView
and a ListView
. Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="20dp">
<TextView
android:text="Bluetooth List"
android:paddingTop="15dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</TextView>
<ListView android:id="@+id/bluetoothPanel_lvBluetooth"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_margin="10dip"
android:drawSelectorOnTop="false">
</ListView>
<LinearLayout
android:orientation="horizontal"
android:paddingLeft="4.0dip"
android:paddingTop="5.0dip"
android:paddingRight="4.0dip"
android:paddingBottom="1.0dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/bluetoothPanel_btnSearch"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:text="Search"
android:layout_weight="1.0" />
<Button
android:id="@+id/bluetoothPanel_btnCancel"
android:layout_width="0.0dip"
android:layout_height="fill_parent"
android:text="Cancel"
android:layout_weight="1.0" />
</LinearLayout>
</LinearLayout>
At the beginning, the ArrayAdapter
that is within the ListView
is empty, and I am dynamically add elements to it.
The problem is, I want to set a fixed size for the ListView
so that it won't change its size upon adding elements dynamically (List of bluetooth devices are shown). Could you please help me to fix my XML?
EDIT:
I am not talking about array size. I am talking about the listview itself (the view), the height of the listview.