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.htmlhttp://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
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
}
});