最近android开发中解决bug时学到的一些技术小结

1.获取本地文件大小

File file = new  File( "/sdcard/default/aaa.txt" );   
long  size =  file.length();   //获取文件大小,单位为bytes  
参考文章: http://jinguo.iteye.com/blog/643445

2.将本地image转成bitmap

Bitmap mIcon1 =
BitmapFactory.decodeResource(context.getResources(),R.drawable.twitter_icon); 
imgview.setImageBitmap(mIcon1); 

File img_File = new File(dirFile, img_name);
bitmap=BitmapFactory.decodeFile(img_File.toString());
参考文章: http://www.cmd100.com/bbs/thread-1434-1-1.html
http://blog.foreverlove.us/1481.html


3.多线程下载图片

参考文章:http://hi.baidu.com/miky%D1%EE_1987/blog/item/ef91bd02950fc43c6a60fb7a.html

用的是方法二,实现了边滑动边显示图片

   08-07再补充一篇:http://www.th7.cn/Program/Android/2011/07/29/35965.shtml

http://www.cnblogs.com/zhangkai281/


4.报错:The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new DialogInterface.OnClickListener(){})

解决办法:

button.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
			}
		});


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值