布局

<?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. AndroidTextView的跑马灯效果,解决复杂布局不能获取焦点的问题
  2. Android:控件布局(相对布局)RelativeLayout(转)
  3. Android 代码改变图片颜色android:tint="@color/main_color" and
  4. Android中的5大布局和网格布局
  5. Android 让一个控件或布局居于底部的办法
  6. Android再学习-20141018-布局-进度条

随机推荐

  1. Android中listview中的button
  2. Android分辨率自适应
  3. ionic打包apk时报错No resource identifi
  4. Android(安卓)的source (需安装 git repo
  5. Service简析
  6. android应用程序最小化的处理方法
  7. android从资源文件中读取文件流显示
  8. 购物车单选计算
  9. Linux-安装ifconfig
  10. vue常用术语、样式与事件绑定 与 列表渲