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

  • SEARCH
  • Home
  • 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 6627889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:04:00+00:00 2026-05-25T22:04:00+00:00

I am developing an application that needs to pair with other devices through Bluetooth.

  • 0

I am developing an application that needs to pair with other devices through Bluetooth. I was having trouble in order to show the list of paired devices in correct manner. I had also viewed the example in the android api (Bluetooth Chat), but i was having the same problem.

The list of paired devices are to big and then hides a search button that are at the bottom of the list.

My xml code is very the same of the example:

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  >
  <TextView android:id="@+id/listpaired_devices"
        android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/title_paired_devices"
    android:visibility="gone"
    android:background="#666"
    android:textColor="#fff"
    android:paddingLeft="5dp" 
  /> 
  <ListView android:id="@+id/paired_devices"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stackFromBottom="true"
    android:layout_weight="1"
  />
  <TextView android:id="@+id/list_new_devices"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/title_other_devices"
    android:visibility="gone"
  /> 
  <ListView android:id="@+id/new_devices"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stackFromBottom="true"
    android:layout_weight="2" 
  />  
  <Button android:id="@+id/btscan"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/btscan"
  />
</LinearLayout>

But and i can’t show the search button at the bottom.
Here my screen:
My Screen

You could see a bit of the button at the bottom of the dialog window.

It’s possible to limit the number of rows shown at the listview ? Can anyone tell me how i can fix this problem

  • 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-25T22:04:01+00:00Added an answer on May 25, 2026 at 10:04 pm

    Firstly some points about your code:

    • layout_weight is only meaningful if an object has no size in a certain dimension, that is you set layout_height or layout_width to 0, so this has no effect on your code.
    • Setting the height of a ListView to wrap_content is pretty meaningless, and even if it works it’s bad practice. Use either ‘fill_parent’ or a definite height.
    • The button is hidden because, as per the point above, the ListViews you have created have no predefined size so take up as much space as they can, pushing the button off the screen.

    So let’s think about what you really have there – it’s just a single list with a button at the bottom (yes you may have headers or multiple sources of data in there but we’ll get onto that).

    The following layout will give you a ListView at the top and a Button at the bottom. The ListView will take up any space not being used by the Button. Notice how the Button is defined before the ListView in the layout – this causes Android to calculate how much height the button takes up before considering the ListView. It then gives the ListView the rest of the height available.

    <RelativeLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      >
      <Button android:id="@+id/btscan"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="@string/btscan"
      />
      <ListView android:id="@+id/all_devices"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/btscan"
        android:stackFromBottom="true"
      />  
    </RelativeLayout>
    

    So that’s the layout. Now lets consider the actual content of your list: you have a header, followed by a list of paired devices, followed by another header and then a list of new devices.

    You can create this using a single Adapter – Commonsware provides a very good implementation called MergeAdapter but you could code your own. MergeAdapter doesn’t directly let you a view (e.g. for the headers) but thankfully Commonsware also provides the SackOfViewsAdapter which allows you to add views to it, and then you can add the SackOfViewsAdapter to the MergeAdapter.

    Here is some pseudo-code which should accomplish what is outlined above.

    // This is the adapter we will use for our list with ListView.setAdapter
    MergeAdapter listAdapter = new MergeAdapter();
    
    // The first header - you'll need to inflate the actual View (myHeaderView1) from some resource
    // using LayoutInflater
    List<View> firstHeaderViews = new List<View();
    firstHeaderViews.add(myHeaderView1);
    SackOfViewsAdapter firstHeaderAdapter = new SackOfViewsAdapter(firstHeaderViews)
    
    // Second header
    List<View> secondHeaderViews = new List<View();
    secondHeaderViews.add(myHeaderView2);
    SackOfViewsAdapter secondHeaderAdapter = new SackOfViewsAdapter(secondHeaderViews);
    
    // Now to add everything to the MergeAdapter
    
    // First goes the first header
    listAdapter.addAdapter(firstHeaderAdapter);
    
    // Now your first list
    listAdapter.addAdapter(firstListAdapter);
    
    // Now your second header
    listAdapter.addAdapter(secondHeaderAdapter);
    
    // Now your second list
    listAdapter.addAdapter(secondListAdapter);
    
    // Now set the adapter to the list
    myList.setAdapter(listAdapter)
    

    The layout produced should look something like this. Note I extended the list to show how it behaves with a list longer than the screen; the button still remains visible. The red box marks the bounds of the screen.

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

Sidebar

Related Questions

I am developing an application that needs to use regini (because of legacy reasons)
I'm developing an application that needs to interact over FTP. For this communication I
I am developing a application that needs to store data with many writes and
I'm developing an application that needs to perform some processing on the user's Outlook
I am developing an application that needs to inform users (around 1800) on a
Hi I am developing an application that needs to work with a complex domain
I am developing an application that needs to read back the whole frame from
I'm developing a small utility application that needs to detect whether another one has
I am developing an internally-facing application that needs to automatically authenticate users via Windows
I'm developing a Ruby on Rails application that needs to allow the user to

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.