android - Unable to populate listview with custom rows when component is above listview -


i'm having issues listview using custom rows loaded database.

if, list screen, place button above listview, no visible rows appear in listview.

however remove button, works fine. want button (or other component) appear above make more user friendly. attached 2 code samples below.

this xml file of listview activity works:

<?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:background="@color/real_red_dark">   <linearlayout     android:id="@+id/llmain"     android:layout_height="fill_parent"     android:background="@drawable/real_background"     android:layout_width="fill_parent"     android:layout_gravity="center"     android:gravity="center">         <listview              android:id="@+android:id/list"                   android:layout_width="fill_parent"             android:layout_height="fill_parent"             android:layout_below="@+id/llbutton"             android:layout_alignparentleft="true" />                 <textview             android:id="@+android:id/empty"             android:layout_width="fill_parent"             android:layout_height="fill_parent"             android:text="@string/no_sessions"             android:textstyle="bold"              android:textsize="18dp"              android:gravity="center"/>     </linearlayout> </linearlayout> 

however, if have button added above it, not show whatsoever:

<?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:background="@color/real_red_dark">   <linearlayout     android:id="@+id/llmain"     android:layout_height="fill_parent"     android:background="@drawable/real_background"     android:layout_width="fill_parent"     android:layout_gravity="center"     android:gravity="center">                 <button          android:id="@+id/btnsearch"         android:layout_width="fill_parent"         android:layout_height="35dip"         android:layout_gravity="center_horizontal"         android:layout_margintop="3dip"         android:layout_marginleft="15dip"         android:layout_marginright="15dip"         android:text="find sessions"         android:textstyle="bold" />         <listview              android:id="@+android:id/list"                   android:layout_width="fill_parent"             android:layout_height="fill_parent"             android:layout_below="@+id/llbutton"             android:layout_alignparentleft="true" />                 <textview             android:id="@+android:id/empty"             android:layout_width="fill_parent"             android:layout_height="fill_parent"             android:text="@string/no_sessions"             android:textstyle="bold"              android:textsize="18dp"              android:gravity="center"/>     </linearlayout> </linearlayout> 

you try adding button programmatically header view in listview itself, rather in xml layout.

use listview.addheaderview(view)

http://developer.android.com/reference/android/widget/listview.html#addheaderview(android.view.view)


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -