zoukankan      html  css  js  c++  java
  • ImageLoader在Gridview中的使用

    原理和ImageLoader在Listview中的使用一样,只有下面的几点变化

    主页面的布局

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 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"
        android:orientation="vertical">
    
        <TextView
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="@android:color/holo_blue_light"
            android:gravity="center"
            android:text="ImagleLoager_Gridview"
            android:textColor="@android:color/white"
            android:textSize="25sp" />
    
        <GridView
            android:id="@+id/gv_imageloader"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:horizontalSpacing="4dip"
            android:numColumns="3"
            android:padding="4dip"
            android:stretchMode="columnWidth"
            android:verticalSpacing="4dip" />
    
    </LinearLayout>
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:orientation="horizontal">
        <ImageView
            android:src="@drawable/ic_launcher"
            android:id="@+id/image"
            android:layout_width="50dp"
            android:layout_height="50dp" />
        <TextView
            android:id="@+id/text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_blue_light"
            android:gravity="center"
            android:text="ImagleLoager_Listview"
            android:textColor="@android:color/white"
            android:textSize="25sp" />
    
    
    </LinearLayout>

    主页面发生改变:其他都不会有变化:

    package application.weiyuan.com.listviewimageloader;
    
    import android.app.Activity;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.widget.GridView;
    import android.widget.ListView;
    
    public class MainActivity extends Activity {
    
        private GridView gridView;
        private ListViewAdapter listViewAdapter;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            initView();
            initData();
        }
    
        private void initView() {
            gridView = (GridView)findViewById(R.id.gv_imageloader);
        }
    
        private void initData() {
    // 创建适配器
            listViewAdapter = new ListViewAdapter(MainActivity.this);
    // 添加适配器到listview中
            gridView.setAdapter(listViewAdapter);
        }
    
    }
  • 相关阅读:
    01 . Nginx简介及部署
    01 . Ansible原理部署及简单应用
    vue css module
    Expected linebreaks to be 'LF' but found 'CRLF'.
    vue SPA设计 history hash
    vue3 createComponent
    vue3 template refs dom的引用、组件的引用、获取子组件的值
    vue3 父组件给子组件传值 provide & inject
    vue3生命周期
    CSS3 transform变换
  • 原文地址:https://www.cnblogs.com/kebibuluan/p/7242610.html
Copyright © 2011-2022 走看看