ListView with other widgets below

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

ListView with other widgets below

Postby gilado74 » Mon Dec 14, 2009 6:06 pm

HI,
I am trying to create layout which contain a listView of 2-3 items, each row contains two TextViews.
Below the list I want to add textView for label and EditText.
In general the screen should look:

-------------------------
text1
text2
-------------------------
text1
text2
-------------------------

Enter text:
[textextextextextextext]

currently I am having the list ready.
In order to handle the list I am using "SimpleAdapter" that using row.xml layout.

Now I am trying to add the label and the EditText but I can't add it to my row layout

How can I do it?




[b]
gilado74
Freshman
Freshman
 
Posts: 5
Joined: Tue Dec 08, 2009 11:34 am

Top

Postby qlimax » Mon Dec 14, 2009 7:33 pm

you dont have to add it to the row.xml but to your (e.g) main.xml
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby gilado74 » Tue Dec 15, 2009 8:54 am

I try this but still have problems
I am using relativeLayout in order to put the widgets one below the other
thus I added the following flag [android:layout_below="@+id/android:list"] to "label" textView
but the label and edittext fields did not appear

as soon as i took off the [android:layout_below="@+id/android:list"] flag
the label and edittext fields appear BUT on top of the list

What I am doing wrong here?

here is main.xml:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.                android:layout_width="fill_parent"
  6.  
  7.                android:layout_height="wrap_content"
  8.  
  9.                android:padding="10px">
  10.  
  11.                
  12.  
  13.         <ListView android:id="@+id/android:list"
  14.  
  15.        android:layout_width="fill_parent"
  16.  
  17.        android:layout_height="fill_parent"/>              
  18.  
  19.  
  20.  
  21.     <TextView android:id="@+id/label"
  22.  
  23.              android:layout_width="fill_parent"
  24.  
  25.              android:layout_height="wrap_content"
  26.  
  27.              android:text="Type here:"
  28.  
  29.              android:layout_below="@+id/android:list"/>
  30.  
  31.  
  32.  
  33.     <EditText android:id="@+id/entry"
  34.  
  35.              android:layout_width="fill_parent"
  36.  
  37.              android:layout_height="wrap_content"
  38.  
  39.              android:background="@android:drawable/editbox_background"
  40.  
  41.              android:layout_below="@id/label" />
  42.  
  43.    
  44.  
  45. </RelativeLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


and here is row.xml
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:layout_width="fill_parent"
  6.  
  7.    android:layout_height="?android:attr/listPreferredItemHeight">
  8.  
  9.  
  10.  
  11.     <LinearLayout
  12.  
  13.        
  14.  
  15.        android:orientation="vertical"
  16.  
  17.        android:layout_width="0dip"
  18.  
  19.        android:layout_weight="1"
  20.  
  21.        android:layout_height="fill_parent">
  22.  
  23.  
  24.  
  25.         <TextView
  26.  
  27.            android:id="@+id/text1"
  28.  
  29.            android:textSize="18sp"
  30.  
  31.            android:layout_width="fill_parent"
  32.  
  33.            android:layout_height="0dip"
  34.  
  35.            android:layout_weight="1"
  36.  
  37.            android:gravity="center_vertical"
  38.  
  39.            android:text="My Application" />
  40.  
  41.            
  42.  
  43.         <TextView  
  44.  
  45.                 android:id="@+id/text2"
  46.  
  47.                 android:textSize="14sp"
  48.  
  49.            android:layout_width="fill_parent"
  50.  
  51.            android:layout_height="0dip"
  52.  
  53.            android:layout_weight="1"
  54.  
  55.            android:singleLine="true"
  56.  
  57.            android:ellipsize="marquee"/>
  58.  
  59.     </LinearLayout>
  60.  
  61.        
  62.  
  63. </LinearLayout>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
gilado74
Freshman
Freshman
 
Posts: 5
Joined: Tue Dec 08, 2009 11:34 am

Postby qlimax » Tue Dec 15, 2009 3:28 pm

the label and the edittext doesn't appear to you, because you set the height of the listview to FILL parent and the edittext below this...->below the whole screen

try this

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <RelativeLayout
  3.  
  4. android:id="@+id/RelativeLayout01"
  5.  
  6. android:layout_width="fill_parent"
  7.  
  8. android:layout_height="fill_parent"
  9.  
  10. xmlns:android="http://schemas.android.com/apk/res/android">
  11.  
  12.  
  13.  
  14.   <ListView android:id="@+id/android:list"
  15.  
  16.        android:layout_width="fill_parent"
  17.  
  18.        android:layout_height="fill_parent"
  19.  
  20.        android:layout_above="@+id/label"
  21.  
  22.        />
  23.  
  24.  
  25.  
  26. <TextView android:id="@+id/label"
  27.  
  28.              android:layout_width="fill_parent"
  29.  
  30.              android:layout_height="wrap_content"
  31.  
  32.              android:text="Type here:"              
  33.  
  34.              android:layout_above="@+id/entry"/>
  35.  
  36.  
  37.  
  38.     <EditText android:id="@+id/entry"
  39.  
  40.              android:layout_width="fill_parent"
  41.  
  42.              android:layout_height="wrap_content"
  43.  
  44.              android:background="@android:drawable/editbox_background"
  45.  
  46.             android:layout_alignParentBottom="true"/>
  47.  
  48.  
  49.  
  50.    
  51.  
  52.  
  53.  
  54. </RelativeLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


int this way the edittext is above the bottom edge of the screen, the label is above the edittext and the listview is above the label and fill the remaining parent space.

let me know,
bye ;)
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby gilado74 » Tue Dec 15, 2009 4:13 pm

Great!!, Thanks, I change it to android:layout_height="wrap_content" and it worked perfectly

By the way,
Is there any flag that can determine how many items exactly will be presented in the List
(The list can be longer and you able scrolling between items but only X item is shown)

Thanks,

g
gilado74
Freshman
Freshman
 
Posts: 5
Joined: Tue Dec 08, 2009 11:34 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 13 guests