Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6753937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:13:15+00:00 2026-05-26T13:13:15+00:00

I am trying to include a ListView within an Activity that is running inside

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:13:16+00:00Added an answer on May 26, 2026 at 1:13 pm

    Set a custom ListAdapter for the list and override the getCount() method so it returns always your fixed size.

    Example: http://jnastase.alner.net/archive/2010/12/19/custom-android-listadapter.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to include a value from a database table within the value
I'm trying to include an EPS figure in a document that will be compiled
I am trying to include the library StringEscapeUtils and everything that I can find
I have a ListView that uses Linkify to create a link to another activity
Trying to include a instance variable in a message that a UIAlertView Shows. lostAlert
While trying to include my own class library in Yii . I used this
I'm trying to include in my Windows Form App a way that when user
I'm trying to add a header to the top of a ListView that is
I'm trying to cache Drawable objects that are included in a listview: I have
I'm trying to include a Facebook share iframe on a site that's served using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.