怎样在android GridView实现动态加载图片啊?

怎样在android GridView实现动态加载图片啊?,第1张

你可以用ArrayList当数据源,每次加一张图片都放到ArrayList里面去,再通过你GridView的设配器通知更新:imgAdapter.notifyDataSetChanged()

ImageView中是不能写文字的,单单的只是向实现文字覆盖图片,可以使用帧布局,运行结果是字符串覆盖在图片上.

代码:

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

<ImageView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:src="@drawable/image"

/>

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="雨松MOMO"

android:background="#FF0000"

android:textColor="#000000"

android:textSize="18dip"

/>

</FrameLayout>


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11265892.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-14
下一篇2023-05-14

发表评论

登录后才能评论

评论列表(0条)

    保存