用Volley让GridView加载网络图片

分享到:

一、布局文件

总共两个布局文件,一个是GridView,还有一个是GridView的item,是NetworkImageView和TextView

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <GridView
        android:id="@+id/photo_wall"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:columnWidth="@dimen/image_thumbnail_size"
        android:gravity="center"
        android:numColumns="auto_fit"
        android:stretchMode="columnWidth"
        android:horizontalSpacing="@dimen/image_thumbnail_spacing"
        android:verticalSpacing="@dimen/image_thumbnail_spacing" >
    </GridView>

</RelativeLayout>
昵    称:
验证码:

相关文档: