你好,我正在尝试学习 json 解析并我解决了一些问题,但我有问题我可以在我的列表视图中获取信息,但我无法拍照,我的日志说
我的代码在这里我更改 url 和一些字符串如何解析 Sub JSONArray 并显示图像?
请帮助我已经谢谢....
04-02 07:59:27.767: W/System.err(1737): java.net.MalformedURLException: Protocol not found: WOW1079.jpg
04-02 07:59:27.815: W/System.err(1737): at java.net.URL.<init>(URL.java:178)
04-02 07:59:27.945: W/System.err(1737): at java.net.URL.<init>(URL.java:127)
04-02 07:59:28.095: W/System.err(1737): at com.example.benm.DownloadImageTask.getBitmap(DownloadImageTask.java:41)
04-02 07:59:28.315: W/System.err(1737): at com.example.benm.DownloadImageTask.doInBackground(DownloadImageTask.java:34)
04-02 07:59:28.465: W/System.err(1737): at com.example.benm.DownloadImageTask.doInBackground(DownloadImageTask.java:1)
04-02 07:59:28.695: W/System.err(1737): at android.os.AsyncTask$2.call(AsyncTask.java:264)
04-02 07:59:28.875: W/System.err(1737): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
04-02 07:59:28.885: W/System.err(1737): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-02 07:59:28.895: W/System.err(1737): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
04-02 07:59:28.907: W/System.err(1737): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
04-02 07:59:28.915: W/System.err(1737): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
04-02 07:59:28.925: W/System.err(1737): at java.lang.Thread.run(Thread.java:856)
04-02 07:59:28.995: W/System.err(1737): java.net.MalformedURLException: Protocol not found: WOW749.jpg
04-02 07:59:29.036: W/System.err(1737): at java.net.URL.<init>(URL.java:178)
04-02 07:59:29.045: W/System.err(1737): at java.net.URL.<init>(URL.java:127)
04-02 07:59:29.055: W/System.err(1737): at com.example.benm.DownloadImageTask.getBitmap(DownloadImageTask.java:41)
04-02 07:59:29.066: W/System.err(1737): at com.example.benm.DownloadImageTask.doInBackground(DownloadImageTask.java:34)
04-02 07:59:29.095: W/System.err(1737): at com.example.benm.DownloadImageTask.doInBackground(DownloadImageTask.java:1)
04-02 07:59:29.155: W/System.err(1737): at android.os.AsyncTask$2.call(AsyncTask.java:264)
04-02 07:59:29.165: W/System.err(1737): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
04-02 07:59:29.175: W/System.err(1737): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-02 07:59:29.185: W/System.err(1737): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
here is my code
公共类 DownloadImageTask 扩展 AsyncTask {
private String mUrl;
private ImageView mImageView = null;
public DownloadImageTask(String Url, ImageView imageView) {
mUrl = Url;
this.mImageView = imageView;
}
protected void onPostExecute(Bitmap result) {
super.onPostExecute(result);
if (result != null) {
mImageView.setImageBitmap(result);
}
}
protected Bitmap doInBackground(Void... params) {
Bitmap bitmap = getBitmap(mUrl);
return bitmap;
}
public Bitmap getBitmap(String imageUrl) {
Bitmap mBitmap = null;
try {
URL url = new URL(imageUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
InputStream is = conn.getInputStream();
mBitmap = BitmapFactory.decodeStream(is);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return mBitmap;
}
}