編輯:初級開發
class myView extends View{ public myVIEw(Context context) {
super(context);
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//read the icon.png into buffer
InputStream is = getResources().openRawResource(R.drawable.icon);
//decode
Bitmap mBitmap = BitmapFactory.decodeStream(is);
Paint mPaint = new Paint();
canvas.drawBitmap(mBitmap, 40, 40, mPaint);
} }
------------------------------------------------用imageVIEw顯示
/**
* 從URL中取得Bitmap,並限制小於指定大小時才載入. 默認200K
* @param strurl URL全路徑
* @return
*/
public static Bitmap getURLBitmap(String strurl)
{
int defaultLargestSize =200 * 1024; // 默認200K
URL imageUrl = null;
Bitmap bitmap = null;
try{
imageUrl = new URL(strurl);
} catch (MalformedURLException e){
e.printStackTrace();
}
try{
HttpGet httpRequest = new HttpGet(imageUrl.toURI());
HttpClient httpclient = new DefaultHttpClIEnt();
HttpResponse response = (HttpResponse) httpclIEnt.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity buffHttpEntity = new BufferedHttpEntity(entity);
if (buffHttpEntity.getContentLength() < defaultLargestSize){
InputStream is = buffHttpEntity.getContent();
bitmap = BitmapFactory.decodeStream(is);
is.close();
}else{
bitmap = null;
}
} catch (Exception e){
e.printStackTrace();
}return bitmap;
}
//實際調用
private Bitmap bmp =null;
ImageView mImageVIEw1;
bmp = Global.getURLBitmap(uriPic+photo_path);
if (bmp == null){
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
bmp = BitmapFactory.decodeResource(this.getResources(), R.drawable.notice);
}
mImageVIEw1.setImageBitmap(bmp);
在android開發中ListView是比較常用的組件,它以列表的形式展示具體內容,並且能夠根據數據的長度自適應顯示。抽空把對ListVIEw的使用做了整理,並寫了個小
1.android模擬器采用的是開源工程Qemu,Qemu是Linux 下的著名模擬器2. kernel-qemu是內核鏡像3. ramdisk.img是文件系統,如果
這篇文章沒有打算有一個很好的邏輯去介紹android的某個方面,全盤大致上就是我接觸、了解android的ui開發後到現在的一些感想以及個人理解吧! &nbs
ps:對於軟件開發人員來說,保護代碼安全也是比較重要的因素之一,不過目前來說Google Android平台選擇了Java Dalvik VM的方式使其程序很容易破解和