How to make a list with a layout file

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

How to make a list with a layout file

Postby puxdroid » Tue Dec 08, 2009 5:47 pm

Hello

I have a layout like this:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4.  
  5.  
  6. <LinearLayout
  7.  
  8.    xmlns:android="http://schemas.android.com/apk/res/android"
  9.  
  10.    android:layout_width="fill_parent"
  11.  
  12.    android:layout_height="wrap_content"
  13.  
  14.    android:minHeight="?android:attr/listPreferredItemHeight"
  15.  
  16.    android:gravity="center_vertical">
  17.  
  18.  
  19.  
  20.     <RelativeLayout
  21.  
  22.        android:id="@+android:id/text_layout"
  23.  
  24.        android:layout_width="wrap_content"
  25.  
  26.        android:layout_height="wrap_content"
  27.  
  28.        android:layout_marginLeft="16sp"
  29.  
  30.        android:layout_marginRight="6sp"
  31.  
  32.        android:layout_marginTop="6sp"
  33.  
  34.        android:layout_marginBottom="6sp"
  35.  
  36.        android:layout_weight="1"
  37.  
  38.        android:focusable="true"
  39.  
  40.        android:background="@android:drawable/menuitem_background">
  41.  
  42.  
  43.  
  44.         <TextView
  45.  
  46.            android:id="@+android:id/title"
  47.  
  48.            android:layout_width="wrap_content"
  49.  
  50.            android:layout_height="wrap_content"
  51.  
  52.            android:focusable="true"
  53.  
  54.            android:singleLine="true"
  55.  
  56.            android:textAppearance="?android:attr/textAppearanceLarge" />
  57.  
  58.  
  59.  
  60.         <TextView
  61.  
  62.            android:id="@+android:id/summary"
  63.  
  64.            android:layout_width="wrap_content"
  65.  
  66.            android:layout_height="wrap_content"
  67.  
  68.            android:layout_below="@android:id/title"
  69.  
  70.            android:layout_alignLeft="@android:id/title"
  71.  
  72.            android:textAppearance="?android:attr/textAppearanceSmall"
  73.  
  74.            android:maxLines="2" />
  75.  
  76.  
  77.  
  78.     </RelativeLayout>
  79.  
  80.  
  81.  
  82.     <RadioButton
  83.  
  84.        xmlns:android="http://schemas.android.com/apk/res/android"
  85.  
  86.        android:id="@+android:id/apn_radiobutton"
  87.  
  88.        android:layout_width="wrap_content"
  89.  
  90.        android:layout_height="wrap_content"
  91.  
  92.        android:layout_marginLeft="4dip"
  93.  
  94.        android:layout_marginRight="4dip"
  95.  
  96.        android:layout_gravity="center_vertical"
  97.  
  98.        android:clickable="true" />
  99.  
  100.  
  101.  
  102. </LinearLayout>
  103.  
  104.  
Parsed in 0.006 seconds, using GeSHi 1.0.8.4


And I need to make a list with this layout and I don't know how to do this.

I know I have to use setListAdapter(), but I'm not sure.

Can anybody help me?

Thanks in advance and sorry for my English.
Last edited by puxdroid on Wed Dec 09, 2009 12:21 pm, edited 1 time in total.
puxdroid
Developer
Developer
 
Posts: 49
Joined: Wed Nov 25, 2009 11:57 am

Top

Postby qlimax » Wed Dec 09, 2009 12:35 am

sorry., it's not clear to me...
do you want that each item of a listview, look as described in the layout you posted?

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

Postby puxdroid » Wed Dec 09, 2009 12:25 pm

Yes, I want to make a kind of preferences. I have seen the code in http://android.git.kernel.org/?p=platfo ... ttings.git but it is not enough for me. It is a bit difficult to understand the code and it doesn't work.
puxdroid
Developer
Developer
 
Posts: 49
Joined: Wed Nov 25, 2009 11:57 am

Postby qlimax » Wed Dec 09, 2009 1:52 pm

take a look to this simple example, it show how to create a listview with your custom layout:

http://www.androidguys.com/2008/07/14/f ... -part-one/

(for an optimized listview, look at the first comment of that post...)

try it, if you have questions :) ask.

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

Postby puxdroid » Wed Dec 16, 2009 2:17 pm

I have founded a link better than http://www.androidguys.com/2008/07/14/f ... -part-one/

This link show us step by step how to make a listview and is the whole code in the page (in the other link not)

http://www.softwarepassion.com/android- ... -adapters/
puxdroid
Developer
Developer
 
Posts: 49
Joined: Wed Nov 25, 2009 11:57 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests