2A01-View-Grid

描述网格包括手机上所有lunch icon


/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.example.android.apis.view;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

import java.util.List;

//Need the following import to get access to the app resources, since this
//class is in a sub-package.
import com.example.android.apis.R;


public class Grid1 extends Activity {

    GridView mGrid;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        loadApps(); // do this in onresume?

        setContentView(R.layout.grid_1);
        mGrid = (GridView) findViewById(R.id.myGrid);
        mGrid.setAdapter(new AppsAdapter());
    }

    private List<ResolveInfo> mApps;

    private void loadApps() {
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

        mApps = getPackageManager().queryIntentActivities(mainIntent, 0);
    }

    public class AppsAdapter extends BaseAdapter {
        public AppsAdapter() {
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i;

            if (convertView == null) {
                i = new ImageView(Grid1.this);
                i.setScaleType(ImageView.ScaleType.FIT_CENTER);
                i.setLayoutParams(new GridView.LayoutParams(50, 50));
            } else {
                i = (ImageView) convertView;
            }

            ResolveInfo info = mApps.get(position);
            i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager()));

            return i;
        }


        public final int getCount() {
            return mApps.size();
        }

        public final Object getItem(int position) {
            return mApps.get(position);
        }

        public final long getItemId(int position) {
            return position;
        }
    }

}


控件使用 1、鼠标经过行的时候改变该行的样式,鼠标离开行的时候恢复该行的样式 使用方法(设置属性): MouseOverCssClass - 鼠标经过行时行的 CSS 类名 2、对多个字段进行复合排序;升序、降序的排序状态提示 使用方法(设置SmartSorting复合属性): AllowSortTip - 是否启用排序提示 AllowMultiSorting - 是否启用复合排序 SortAscImageUrl - 升序提示图片的URL(不设置则使用默认图片) SortDescImageUrl - 降序提示图片的URL(不设置则使用默认图片) SortAscText - 升序提示文本 SortDescText - 降序提示文本 3、根据按钮的CommandName设置其客户端属性 使用方法(设置ClientButtons集合属性): BoundCommandName - 需要绑定的CommandName AttributeKey - 属性的名称 AttributeValue - 属性的值(两个占位符:{0} - CommandArgument;{1} - Text) Position - 属性的值的位置 4、联动复选框(复选框的全选和取消全选)。选中指定的父复选框,则设置指定的所有子复选框为选中状态;取消选中指定的父复选框,则设置指定的所有子复选框为取消选中状态。如果指定的所有子复选框为均选中状态,则设置指定的父复选框为选中状态;如果指定的所有子复选框至少有一个为取消选中状态,则设置指定的父复选框为取消选中状态 使用方法(设置CascadeCheckboxes集合属性): ParentCheckboxID - 模板列中 父复选框ID ChildCheckboxID - 模板列中 子复选框ID CashBox.Helper.WebGrid中的静态方法 List GetCheckedDataKey(GridView gv, int columnIndex) List GetCheckedDataKey(GridView gv, string checkboxId) 5、固定指定行、指定列,根据RowType固定行,根据RowState固定行 使用方法(设置FixRowColumn复合属性): FixRowType - 需要固定的行的RowType(用逗号“,”分隔) FixRowState - 需要固定的行的RowState(用逗号“,”分隔) FixRows - 需要固定的行的索引(用逗号“,”分隔) FixColumns - 需要固定的列的索引(用逗号“,”分隔) TableWidth - 表格的宽度 TableHeight - 表格的高度 6、响应行的单击事件和双击事件,并在服务端处理 使用方法(设置属性): BoundRowClickCommandName - 行的单击事件需要绑定的CommandName BoundRowDoubleClickCommandName - 行的双击事件需要绑定的CommandName 7、行的指定复选框选中的时候改变该行的样式,行的指定复选框取消选中的时候恢复该行的样式 使用方法(设置CheckedRowCssClass复合属性): CheckBoxID - 模板列中 数据行的复选框ID CssClass - 选中的行的 CSS 类名 8、导出数据源的数据为Excel、Word或Text(应保证数据源的类型为DataTable或DataSet) 使用方法: 为WebGrid添加的方法 Export(string fileName) Export(string fileName, ExportFormat exportFormat) Export(string fileName, ExportFormat exportFormat, Encoding encoding) Export(string fileName, int[] columnIndexList, ExportFormat exportFormat, Encoding encoding) Export(string fileName, int[] columnIndexList, string[] headers, ExportFormat exportFormat, Encoding encoding) Export(string fileName, string[] columnNameList, ExportFormat exportFormat, Encoding encoding) Export(string fileName, strin
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值