随笔 - 0, 文章 - 264, 评论 - 170, 引用 - 0

导航

<2025年3月>
2324252627281
2345678
9101112131415
16171819202122
23242526272829
303112345

留言簿(6)

随笔分类

文章分类

文章档案

AI

android+移动开发

apache等开源类包,工具相关

cdn

concurrent

C语言

git、svn等工具使用

groovy、grails

Hadoop、Storm、Spark大数据相关

hibernate、JPA等持久化技术

html,dom,js,css、ext、mui等前端、移动前端相关

HTTP、HTTPS、TCP、UDP等协议相关

IM、openfire

Java基础

java性能优化

jquery

linux相关

lucene、solr等搜索技术相关

maven gradle ant Jenkins自动化构建与持续集成

memcache

mongodb

nginx、squid、haproxy、varnish

OLAP

python、shell、perl、php

redis

rmi相关

spring

struts、webwork

tcp/ip

tomcat,jsp,servlet相关

velocity等实用工具相关

业务相关

互联网安全、过滤、网络

修炼

其他

区块链

压力、性能测试相关

地图相关

基础

多线程

开发工具相关

数据库

架构

移动互联网

设计模式

搜索

  •  

最新评论

android中展示图片

 1    1public class Images extends Activity  
 2    2. {  
 3    3.     private Uri[] mUrls;  
 4    4.     String[] mFiles=null;  
 5    5.   
 6    6.     public void onCreate(Bundle icicle)  
 7    7.     {  
 8    8.   
 9    9.         super.onCreate(icicle);  
10   10.         setContentView(R.layout.images);  
11   11.   
12   12.         File images = Environment.getDataDirectory();  
13   13.         File[] imagelist = images.listFiles(new FilenameFilter(){  
14   14.         @override  
15   15.         public boolean accept(File dir, String name)  
16   16.         {  
17   17.             return ((name.endsWith(".jpg"))||(name.endsWith(".png"))  
18   18.         }  
19   19.     });  
20   20.         mFiles = new String[imagelist.length];  
21   21.   
22   22.         for(int i= 0 ; i< imagelist.length; i++)  
23   23.         {  
24   24.             mFiles[i] = imagelist[i].getAbsolutePath();  
25   25.         }  
26   26.         mUrls = new Uri[mFiles.length];  
27   27.   
28   28.         for(int i=0; i < mFiles.length; i++)  
29   29.         {  
30   30.             mUrls[i] = Uri.parse(mFiles[i]);     
31   31.         }     
32   32.   
33   33.         Gallery g = (Gallery) findViewById(R.id.gallery);  
34   34.         g.setAdapter(new ImageAdapter(this));  
35   35.         g.setFadingEdgeLength(40);  
36   36.     }  
37   37.     public class ImageAdapter extends BaseAdapter{  
38   38.           
39   39.         int mGalleryItemBackground;  
40   40.         public ImageAdapter(Context c)  {     
41   41.             mContext = c;     
42   42.         }  
43   43.         public int getCount(){  
44   44.             return mUrls.length;  
45   45.         }  
46   46.         public Object getItem(int position){  
47   47.             return position;  
48   48.         }  
49   49.         public long getItemId(int position) {  
50   50.             return position;  
51   51.         }  
52   52.         public View getView(int position, View convertView, ViewGroup parent){  
53   53.             ImageView i = new ImageView(mContext);  
54   54.   
55   55.             i.setImageURI(mUrls[position]);  
56   56.             i.setScaleType(ImageView.ScaleType.FIT_XY);  
57   57.             i.setLayoutParams(new Gallery.LayoutParams(260210));  
58   58.             return i;  
59   59.         }     
60   60.         private Context mContext;  
61   61.         }     
62   62.     } 

posted on 2010-10-26 09:34 小一败涂地 阅读(1987) 评论(0)  编辑  收藏 所属分类: android+移动开发


只有注册用户登录后才能发表评论。


网站导航: