Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/215.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android GridView中包含不同的项目_Android_Gridview - Fatal编程技术网

Android GridView中包含不同的项目

Android GridView中包含不同的项目,android,gridview,Android,Gridview,我跟踪了Hello grid view turtorial。我想知道是否有一种方法可以在网格视图中沿图像的一侧添加按钮?如果是这样的话,我该怎么做呢?您可以尝试以下方法: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.c

我跟踪了Hello grid view turtorial。我想知道是否有一种方法可以在网格视图中沿图像的一侧添加按钮?如果是这样的话,我该怎么做呢?

您可以尝试以下方法:

<?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>

希望能有所帮助。

这是可能的,因为所有小部件都是视图的子类。请查看此项。这将在GridView旁边添加一个按钮,但不会添加到GridView中的每个项目。我明白了,在这种情况下,我建议查看