0

I followed the Hello grid view turtorial at here. I was wondering is there a way to add buttons along side the images in a grid view? if so how can i do it?

Xwire
  • 77
  • 1
  • 8

1 Answers1

0

You could try something like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <GridView xmlns:android="http://schemas.android.com/apk/res/android" 
            android:id="@+id/gridview"
            android:layout_width="fill_parent" 
            android:layout_height="300dp"
            android:columnWidth="90dp"
            android:numColumns="auto_fit"
            android:verticalSpacing="10dp"
            android:horizontalSpacing="10dp"
            android:stretchMode="columnWidth"
            android:gravity="center"  
     />

    <Button
          android:id="@+id/bAdd"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Add RES"
          android:layout_below="@+id/gridview" />

</RelativeLayout>

Hope that helps.

0gravity
  • 2,682
  • 4
  • 24
  • 33
  • this will add a button adjacent to the GridView, but not to each item in the GridView. – Abhijit Jul 03 '12 at 01:03
  • I see, in that case I would suggest looking at http://stackoverflow.com/questions/775188/add-an-array-of-buttons-to-a-gridview-in-an-android-application – 0gravity Jul 03 '12 at 01:09