zoukankan      html  css  js  c++  java
  • Gallery

    Gallery画廊

    Gallery控件与Spinner类相似,都是AbsSpinner类的子类。

    Spinner显示的是一个垂直列表选择,Gallery显示的是一个水平列表选择框,(允许用户水平拖动列表框)

    方法

    属性

    描述

    public Gallery(Context context)

    创建Gallery对象

    public void setSpacing(int spacing)

    android: spacing

    设置两个图片之间的显示间距

    public void setAdapter(

           SpinnerAdapter adapter)

    设置图片集

    public void setGravity(int gravity)

    android: gravity

    设置图片的对齐方式

    public void setOnItemClickListener(

        AdapterView.OnItemClickListener)

    设置选项单击事件

    复制代码
    Gallery ga=(Gallery) findViewById(R.id.gallery);
    // 读到png结尾的图片
    Field[] fields = R.drawable.class.getDeclaredFields();
    List<Map<String, Integer>> data = new ArrayList<Map<String, Integer>>();
    for (Field field : fields) {
        Map<String, Integer> map = new HashMap<String, Integer>();
        try {
            map.put("img", field.getInt(R.drawable.class));
            data.add(map);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.gallery,
           new String[] { "img" },new int[] { R.id.gaImg });
    ga.setAdapter(adapter);
    复制代码
  • 相关阅读:
    外观模式
    解释器模式
    LoadRunner学习笔记(三)
    lr 中cookie的解释与用法
    LR使用web_add_cookie函数进行cookie模拟
    LoadRunner学习笔记(二)
    SVN服务器搭建和使用
    使用Jmeter监测服务器性能指标
    jmeter 使用白皮书
    intellij idea创建maven项目
  • 原文地址:https://www.cnblogs.com/dahaoheshan/p/6999433.html
Copyright © 2011-2022 走看看