android 入门学习笔记attr.xml TypedArray obtainStyledAttributes 使用
来源:互联网 发布:js canvas渐变闪烁 编辑:程序博客网 时间:2024/05/21 11:41
需要引入
import android.content.res.Resources;import android.content.res.TypedArray;
obtainStyledAttributes 作用就是从我们自己定义的attr.xml读取所需信息
public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; private Context mContext; private Integer[] myImageIds; public ImageAdapter(Context c, Integer[] aid) { mContext = c; myImageIds = aid; TypedArray a = obtainStyledAttributes(R.styleable.Gallery); mGalleryItemBackground = a.getResourceId ( R.styleable.Gallery_android_galleryItemBackground, 0 ); a.recycle(); } @Override public int getCount() { // TODO Auto-generated method stub return myImageIds.length; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return null; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView (int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub /*产生ImageView对象*/ ImageView i = new ImageView(mContext); /*设置图片给imageView对象*/ i.setImageResource(myImageIds[position]); /*重新设置图片的宽高*/ i.setScaleType(ImageView.ScaleType.FIT_XY); /*重新设置Layout的宽高*/ i.setLayoutParams(new Gallery.LayoutParams(138, 108)); /*设置Gallery背景图*/ i.setBackgroundResource(mGalleryItemBackground); /*返回imageView对象*/ return i; } }
- android 入门学习笔记attr.xml TypedArray obtainStyledAttributes 使用
- 【Android】TypedArray和obtainStyledAttributes使用
- 【Android】TypedArray和obtainStyledAttributes使用
- android菜瓜笔记之TypedArray和obtainStyledAttributes使用场景
- android菜瓜笔记之TypedArray和obtainStyledAttributes使用场景
- android菜瓜笔记之TypedArray和obtainStyledAttributes使用场景
- Android自定义属性--------TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- TypedArray和obtainStyledAttributes使用
- asp.net从后台动态添加用户控件
- 文档编写标准化
- 在web.config里面怎么设置FORMS验证:某几个页面可以匿名访问,其他页面都需要登录
- 第一次创业失败的总结 - 产品设计
- 前端js中解析XML文件(一)
- android 入门学习笔记attr.xml TypedArray obtainStyledAttributes 使用
- 大数阶乘
- 忘记UBUNTU密码
- Developing Windows Applications in C++
- 理解PHP标识符
- 随视云平台论坛正式开通:http://blog.csdn.net/adsitbbs
- Eclipse.ini配置文件解析
- CentOS下配置MySQL Master-Master的步骤
- 大数加法