/*
* Copyright (C) 2008 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 net.sunniwell.spinnerdroplayout;
import java.util.ArrayList;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
/**
* Adapter showing the types of items that can be added to a {@link Workspace}.
* <br>接口,用于显示项目的类型,可以添加到{@link Workspace}中的项目�? */
public class AddAdapter extends BaseAdapter {
private final LayoutInflater mInflater;
private final ArrayList<ListItem> mItems = new ArrayList<ListItem>();
public static final int ITEM_SHORTCUT = 0;
public static final int ITEM_APPWIDGET = 1;
public static final int ITEM_LIVE_FOLDER = 2;
public static final int ITEM_WALLPAPER = 3;
/**
* Specific item in our list.
* <br>我们的list要显示的项目
*/
public class ListItem {
public final CharSequence text;
public final Drawable image;
public final int actionTag;
public ListItem(Resources res, int textResourceId, int imageResourceId, int actionTag) {
text = res.getString(textResourceId);
if (imageResourceId != -1) {
image = res.getDrawable(imageResourceId);
} else {
image = null;
}
this.actionTag = actionTag;
}
}
public AddAdapter(Main launcher) {
super();
/**
* 以下两种方式均可以:
*/
// mInflater = getLayoutInflater(); // 在Activity里面才行
// LayoutInflater inflater = LayoutInflater.from(context);// 也行�?
mInflater = (LayoutInflater) launcher.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// Create default actions
Resources res = launcher.getResources();
mItems.add(new ListItem(res, R.string.group_shortcuts,
R.drawable.ic_launcher_shortcut, ITEM_SHORTCUT));
mItems.add(new ListItem(res, R.string.group_widgets,
R.drawable.ic_launcher_appwidget, ITEM_APPWIDGET));
mItems.add(new ListItem(res, R.string.group_live_folders,
R.drawable.ic_launcher_folder_live, ITEM_LIVE_FOLDER));
mItems.add(new ListItem(res, R.string.group_wallpapers,
R.drawable.ic_launcher_gallery, ITEM_WALLPAPER));
}
public View getView(int position, View convertView, ViewGroup parent) {
ListItem item = (ListItem) getItem(position);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.add_list_item, parent, false);
}
TextView textView = (TextView) convertView;
textView.setTag(item);
//.........................
textView.setText(item.text);
textView.setCompoundDrawablesWithIntrinsicBounds(item.image, null, null, null);
return convertView;// 齐霜给我讲清楚了,址引用?
}
public int getCount() {
return mItems.size();
}
public Object getItem(int position) {
return mItems.get(position);
}
public long getItemId(int position) {
return position;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
ListItem item = (ListItem) getItem(position);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.drop_list_item, parent, false);
}
TextView textView = (TextView) convertView;
textView.setTag(item);
textView.setText(item.text+"DRtest");
textView.setCompoundDrawablesWithIntrinsicBounds(item.image, null, null, null);
return textView;
}
}
大富大贵7
- 粉丝: 393
- 资源: 8870
最新资源
- NSArgumentNullException如何解决.md
- VueError解决办法.md
- buvid、did参数生成算法
- tiny-cuda-cnn.zip
- 关于月度总结的PPT模板
- 手表品牌与型号数据集,手表型号数据
- 基于Java实现(IDEA)的贪吃蛇游戏-源码+jar文件+项目报告
- 数字按键3.2考试代码
- 颜色拾取器 for Windows
- 台球检测40-YOLO(v5至v11)、COCO、CreateML、Paligemma、TFRecord、VOC数据集合集.rar
- # 基于MATLAB的导航科学计算库
- Qt源码ModbusTCP 主机客户端通信程序 基于QT5 QWidget, 实现ModbusTCP 主机客户端通信,支持以下功能: 1、支持断线重连 2、通过INI文件配置自定义服务器I
- tesseract ocr 训练相关的环境部署包,包括jdk-8u331-windows-x64.exe、jTessBoxEditorFX-2.6.0.zip 等
- 好用的Linux终端管理工具,支持自定义多行脚本命令,密码保存、断链续接,SFTP等功能
- 大学毕业设计写作与答辩指南:选题、研究方法及PPT制作
- 小偏差线性化模型,航空发动机线性化,非线性系统线性化,求解线性系统具体参数,最小二乘拟合 MATLAB Simulink 航空发动机,非线性,线性,非线性系统,线性系统,最小二乘,拟合,小偏差,系统辨
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈