zoukankan      html  css  js  c++  java
  • 【安卓6】高级控件—— 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);
    Gallery部分java代码
  • 相关阅读:
    织梦开发——相关阅读likeart应用
    织梦标签教程
    织梦专题调用代码
    HIT 2543 Stone IV
    POJ 3680 Intervals
    HIT 2739 The Chinese Postman Problem
    POJ 1273 Drainage Ditches
    POJ 2455 Secret Milking Machine
    SPOJ 371 Boxes
    HIT 2715 Matrix3
  • 原文地址:https://www.cnblogs.com/leelee/p/6994633.html
Copyright © 2011-2022 走看看