/*
* 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;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
小程序 Spinner图文混排源码.rar
共30个文件
class:8个
png:8个
xml:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 55 浏览量
2023-02-03
11:40:41
上传
评论
收藏 167KB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序 Spinner图文混排源码.rar (30个子文件)
1-12101Q35T40-L.png 33KB
1_121018140206_1.png 64KB
Android Spinner图文混排源码
SpinnerDropLayout
.classpath 280B
.settings
org.eclipse.core.resources.prefs 88B
assets
src
net
sunniwell
spinnerdroplayout
AddAdapter.java 4KB
Main.java 1KB
res
drawable-mdpi
drawable-ldpi
values
strings.xml 992B
layout
add_list_item.xml 1KB
drop_list_item.xml 1KB
drawable
ic_menu_notifications.png 2KB
ic_launcher_gallery.png 3KB
ic_launcher_appwidget.png 3KB
ic_launcher_shortcut.png 3KB
ic_launcher_folder_live.png 3KB
icon.png 4KB
drawable-hdpi
bin
resources.ap_ 22KB
net
sunniwell
spinnerdroplayout
R$string.class 624B
R$layout.class 480B
Main.class 1KB
AddAdapter$ListItem.class 1KB
R$attr.class 379B
R$drawable.class 663B
AddAdapter.class 3KB
R.class 567B
SpinnerDropLayout.apk 26KB
classes.dex 6KB
default.properties 364B
.project 853B
AndroidManifest.xml 690B
gen
net
sunniwell
spinnerdroplayout
R.java 1KB
共 30 条
- 1
资源评论
大富大贵7
- 粉丝: 389
- 资源: 8868
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功