編輯:關於Android編程
[java]
復制代碼 代碼如下:
public static Bitmap getBitmapFromServer(String imagePath) {
HttpGet get = new HttpGet(imagePath);
HttpClient client = new DefaultHttpClient();
Bitmap pic = null;
try {
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
pic = BitmapFactory.decodeStream(is); // 關鍵是這句代碼
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return pic;
}
public static Bitmap getBitmapFromServer(String imagePath) {
HttpGet get = new HttpGet(imagePath);
HttpClient client = new DefaultHttpClient();
Bitmap pic = null;
try {
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
pic = BitmapFactory.decodeStream(is); // 關鍵是這句代碼
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return pic;
}
其中imagePath是你的圖片路徑,
最後可以將圖片顯示在手機上:
[java]
復制代碼 代碼如下:
imageView.setImageBitmap(bitmap);
Android-AlertDialog各種對話框的用法
目標效果: 程序運行,顯示圖一的幾個按鈕,點擊按鈕分別顯示圖二到圖六的對話框,點擊對話框的某一項或者按鈕,也會顯示相應的吐司輸出。 1.activity_
Android實現彈幕功能
大家好,感覺好像已經很久沒更新博客了。前段時間主要是忙於新書的事情,時間比較緊張。而現在新書已經完稿,剩下的事情就都 是出版社的工作了,那麼我又可以抽出時間來寫寫博客了。
Android7.0 Rild工作流程
一、基於Rild的通信架構一般智能手機的硬件架構都是兩個處理器:一個處理器用來運行操作系統,上面運行應用程序,這個處理器稱作Application Processor,簡
android studio for android learning (二十一 )異步任務AsyncTask加載美女圖片攻略及AsyncTask源碼詳解
1.android 的UI線程阻超過5秒就會引發ANR(Application not responding)異常,如果等待超過3秒,你就會失去用戶。2.在android
Notification(Notification的通知欄常駐、Notification的各種樣式、Notification點擊無效)
Android的Notification是android系統中很重要的一