我试图实现从这里获得的图像异步任务:
http://schimpf.es/asynctask-for-image-download/
然后我尝试在我的代码中执行它,如下所示:
ImageView im1 = (ImageView) findViewById(R.id.image);
ImageDownloadTask imageD = new ImageDownloadTask(im1);
imageD.execute(e.mediumLabel);
图片永远加载不出来......
我的 xml 文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/beerTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="40sp"
android:textStyle = "bold"
android:padding="5dip"
>
</TextView>
<ImageView android:id="@+id/image"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_margin="10dip"/>
<Button
android:id="@+id/buttonBrewery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:text="" />
<Button
android:id="@+id/buttonStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dip"
android:text="" />
<TextView
android:id="@+id/beerDEscriptionTitle"
android:textStyle = "bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="20sp"
android:text="Description"
android:padding="5dip"
></TextView>
<TextView
android:id="@+id/beerDescription"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="15sp"
android:padding="5dip"
></TextView>
</LinearLayout>
</ScrollView>