Android:在gridview中为图像添加复选框
我在gridView中显示了图像,现在我需要为每个图像添加一个复选框,以便允许多个选择 Q:如何在android的网格视图中将复选框添加到图像?Android:在gridview中为图像添加复选框,android,gridview,Android,Gridview,我在gridView中显示了图像,现在我需要为每个图像添加一个复选框,以便允许多个选择 Q:如何在android的网格视图中将复选框添加到图像? (例如,Gallery应用程序具有相同的功能)您可以创建简单复选框(http://developer.android.com/reference/android/widget/CheckBox.html)并使用setCompoundDrawables向其添加图标。而不仅仅是将此组件添加到网格中 您可以创建简单复选框(http://developer.a
(例如,Gallery应用程序具有相同的功能)您可以创建简单复选框(http://developer.android.com/reference/android/widget/CheckBox.html)并使用setCompoundDrawables向其添加图标。而不仅仅是将此组件添加到网格中 您可以创建简单复选框(http://developer.android.com/reference/android/widget/CheckBox.html)并使用setCompoundDrawables向其添加图标。而不仅仅是将此组件添加到网格中 您可以使用FrameLayout
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dip"
android:padding="5dip">
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:layout_gravity="right|center_vertical"
android:background="@drawable/delete"/>
<CheckBox
android:id="@+id/chk_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
您可以对其使用FrameLayout
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="9dip"
android:padding="5dip">
<ImageView
android:id="@+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:layout_gravity="right|center_vertical"
android:background="@drawable/delete"/>
<CheckBox
android:id="@+id/chk_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</FrameLayout>
检查此项,了解如何在gridview中创建带有图标的textview
从该链接获取帮助,只需将textView替换为复选框即可。查看此链接,了解如何在gridview中创建带有图标的textView
从该链接获取帮助,只需将文本视图替换为复选框。签出此代码,它将帮助您
签出此代码,它将帮助您
你可以在GridView中使用框架布局你可以在GridView中使用框架布局我试图从gallery中获取图像,而不是图标,结果我崩溃了。我指的是标准gallery应用程序。我尝试了同样的方法,但遇到了问题。我试图从图库中获取图像,而不是图标,结果我崩溃了。我指的是标准图库应用程序。我尝试了同样的方法,但我遇到了问题。你可以看看我的,我刚刚做的。你可以看看我的,我刚刚做的。