我正在尝试在 android 中显示图像。过程是我从网上下载 1 张图像并尝试在屏幕上显示它,我面临的问题是在活动屏幕中我无法设置内容视图和图像.以下是代码:
主.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
</LinearLayout>
活动画面:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.);---->Here i cant set as main
Bitmap bitmap = DownloadImage(
"http://www.allindiaflorist.com/imgs/arrangemen4.jpg");
ImageView img = (ImageView) findViewById(R.id.); //here i cant set the image id
img.setImageBitmap(bitmap);
}