Add button to each row in listview

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

Add button to each row in listview

Postby SamB09 » Wed Jan 20, 2010 4:23 pm

Hi guys, i've got a custom list view in which i want to display a button on each row of the list view , the data comes from a database. This is what i have so far .. it just sets the button to the top which is expected as i dont know how to tell it to go to each row.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.              android:layout_width="fill_parent"
  7.  
  8.              android:layout_height="fill_parent"
  9.  
  10.              android:background="#ff99ccff"
  11.  
  12.              
  13.  
  14. android:orientation="vertical" >
  15.  
  16. <TextView android:id="@+id/text"
  17.  
  18.  android:layout_width="wrap_content"
  19.  
  20.  android:layout_height="wrap_content"
  21.  
  22.  android:background="#ff99ccff"
  23.  
  24.              
  25.  
  26.  android:text="Text view" />
  27.  
  28.              
  29.  
  30. <Button
  31.  
  32. android:id="@+id/btn2"
  33.  
  34. android:layout_width="wrap_content"
  35.  
  36. android:layout_height="wrap_content"
  37.  
  38. android:text="Button"
  39.  
  40. android:layout_x="62px"
  41.  
  42. android:layout_y="314px"
  43.  
  44. >
  45.  
  46. </Button>
  47.  
  48.         <Button
  49.  
  50. android:id="@+id/btn3"
  51.  
  52. android:layout_width="wrap_content"
  53.  
  54. android:layout_height="wrap_content"
  55.  
  56. android:text="Button"
  57.  
  58. android:layout_x="62px"
  59.  
  60. android:layout_y="314px"
  61.  
  62. >
  63.  
  64. </Button>
  65.  
  66.    
  67.  
  68. <ListView
  69.  
  70. android:id="@+id/list"
  71.  
  72. android:layout_width="wrap_content"
  73.  
  74. android:layout_height="wrap_content"
  75.  
  76. android:background="#ff99ccff"
  77.  
  78. android:layout_x="150px"
  79.  
  80. android:layout_y="155px"
  81.  
  82. >
  83.  
  84.  
  85.  
  86. </ListView>
  87.  
  88.  
  89.  
  90. <Button
  91.  
  92. android:id="@+id/btn1"
  93.  
  94. android:layout_width="wrap_content"
  95.  
  96. android:layout_height="wrap_content"
  97.  
  98. android:text="Button"
  99.  
  100. android:layout_x="62px"
  101.  
  102. android:layout_y="314px"
  103.  
  104. >
  105.  
  106. </Button>
  107.  
  108. </LinearLayout>
Parsed in 0.005 seconds, using GeSHi 1.0.8.4
SamB09
Developer
Developer
 
Posts: 39
Joined: Tue Oct 27, 2009 9:22 pm
Location: England

Top

Postby Skeniver » Thu Jan 21, 2010 3:05 pm

Check the post I put here: http://www.anddev.org/image_in_the_lisview-t10483.html

You need to make a custom ListView item and adapter. Then populate the adapter with an ArrayList of your custom types...
Follow me on twitter -> http://twitter.com/Skeniver
Apps & blog -> http://www.formidableapps.co.uk
User avatar
Skeniver
Senior Developer
Senior Developer
 
Posts: 106
Joined: Tue Feb 03, 2009 3:51 pm
Location: Canterbury, UK

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: abhinav123 and 5 guests