预览加载中,请您耐心等待几秒...
1/6
2/6
3/6
4/6
5/6
6/6

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

10publicstaticBitmapzoomBitmap(Bitmapbitmap,intw,inth){ 02 intwidth=bitmap.getWidth(); 03 intheight=bitmap.getHeight(); 04 Matrixmatrix=newMatrix(); 05 floatscaleWidht=((float)w/width); 06 floatscaleHeight=((float)h/height); 07 matrix.postScale(scaleWidht,scaleHeight); 08 Bitmapnewbmp=Bitmap.createBitmap(bitmap,0,0,width,height,matrix,true); 09 returnnewbmp; } =(ImageSwitcher)findViewById(R.id.switcher01); mSwitcher.setFactory(this); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,android.R.anim.fade_in)); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,android.R.anim.fade_out)); g=(Gallery)findViewById(R.id.gallery01); //如果要从sdcard取图片需要改为newImageAdapter(this,getSD());其中getSD()为自定义的方法 g.setAdapter(newImageAdapter(this,getSD())); g.setOnItemSelectedListener(this); //为单击mSwitcher设置一个监听器 //显示Switcher里的模式 @Override publicViewmakeView(){ //TODOAuto-generatedmethodstub ImageViewi=newImageView(this); i.setBackgroundColor(0xFF000000); i.setScaleType(ImageView.ScaleType.FIT_CENTER); i.setLayoutParams(newImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); returni; } //将gallery中选中的图片传给ImageSwitcher @Override publicvoidonItemSelected(AdapterView<?>parent,Viewv,intposition, longid){ //TODOAuto-generatedmethodstub //取的当前图片路径,并将图片的路径给了mSwitcher path=files[position].getPath(); uri=Uri.parse("file://"+path); //System.out.println(uri); mSwitcher.setImageURI(uri); itemId=position; } publicclassImageAdapterextendsBaseAdapter{ intmGalleryItemBackground; privateContextmContext; privateList<String>list; publicImageAdapter(){} publicImageAdapter(Contextc,List<String>li){ mContext=c; list=li; } @Override publicintgetCount(){ //TODOAuto-generatedmethodstub returnlist.size(); } @Override publicObjectgetItem(intposition){ //TODOAuto-generatedmethodstub returnposition; } @Override publiclonggetItemId(intposition){ //TODOAuto-generatedm