布局

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    >  <Button  android:id="@+id/btn"  android:layout_width="fill_parent"  android:layout_height="wrap_content"  android:text="查看" />  <ImageButton  android:id="@+id/imageView"  android:layout_width="fill_parent"  android:layout_height="200px" /></LinearLayout>


C#代码

        protected override void OnCreate(Bundle bundle)        {            base.OnCreate(bundle);            // Set our view from the "main" layout resource            SetContentView(Resource.Layout.Main);            Button btn = FindViewById<Button>(Resource.Id.btn);                       btn.Click += new EventHandler(btn_Click);                                }        void btn_Click(object sender, EventArgs e)        {            ImageView imgview = FindViewById<ImageView>(Resource.Id.imageView);            imgview.SetImageBitmap(getImage("http://hiphotos.baidu.com/baidu/pic/item/7d8aebfebf3f9e125c6008d8.jpg"));        }        public static Bitmap getImage(string imagepath) {                        URL url=null;            Bitmap bitmap = null;            try            {                url = new URL(imagepath);            }            catch (Exception e)            {            }             HttpURLConnection conn = (HttpURLConnection)url.OpenConnection();            conn.DoInput = true;            conn.Connect();            System.IO.Stream str = conn.InputStream;            bitmap = BitmapFactory.DecodeStream(str);            str.Close();            return bitmap;        }

更多相关文章

  1. 【30篇突击 android】源码统计二
  2. 基本控件学习以( RadioGroup和RadioButton 的学习使用)
  3. Android(安卓)Activity 常用功能设置(全屏、横竖屏等)
  4. Android(安卓)曲线绘制Demo
  5. Android(安卓)删除手机联系人,添加手机联系人,更新手机联系人信
  6. Android(安卓)代码改变图片颜色android:tint="@color/main_color
  7. eclipse中关联android源码
  8. android 代码proguard
  9. Android编程: 调试方法

随机推荐

  1. 开发android,我们需要哪些技能基础。
  2. Android(安卓)http中文乱码问题 转
  3. Android中图像变换Matrix的原理、代码验
  4. Android初次使用遇到的两个问题
  5. [转]android Android(安卓)SDK Setup的使
  6. Android(安卓)SDK Installed On Mac
  7. android sdk配置
  8. 在android中使用SOAP与webservice进行数
  9. 在Android中查看和管理sqlite数据库
  10. Android俄罗斯方块游戏源码