zoukankan      html  css  js  c++  java
  • ImageView 设置图片来自:http://blog.csdn.net/lincyang/article/details/6562163

    android doc中是这样描述的:
    
    
    
    public void setImageResource (int resId)
    
    这是其中的一个方法,参数resld是这样:
    
    ImageView.setImageResource(R.drawable.icon);
    
     
    
    看下面这段话
    
    
    
    Sets a drawable as the content of this ImageView.
    
    This does Bitmap reading and decoding on the UI thread, which can cause a latency hiccup. If that's a concern, consider usingsetImageDrawable(Drawable) or setImageBitmap(Bitmap) and BitmapFactory instead.
    
     
    
    此函数使用UI线程,可以用下面3种替代:
    
    ImageView iv; 
    
    String fileName = "/data/data/com.test/aa.png; 
    Bitmap bm = BitmapFactory.decodeFile(fileName); 
    iv.setImageBitmap(bm); 
    
    
    ImageView iv = new ImageView(context); 
    iv.setImageResource(iv[position]); 
    iv.setScaleType(ImageView.ScaleType.FIT_XY); 
    iv.setLayoutParams(new Gallery.LayoutParams(136,88)); 
    
    
    mImageView = (ImageView)this.findViewById(R.id.myImageView1); 
    mImageView.setImageDrawable(getResources().getDrawable(R.drawable.right)
  • 相关阅读:
    java generic type
    android avoiding-memory-leaks
    a various of context
    LruCache
    Java Reference
    SQL join
    Eclipse java中一个工程引用另一个工程的类
    java 匿名内部类的方法参数需要final吗?
    java的final
    如何将每一条记录放入到对应的范围中
  • 原文地址:https://www.cnblogs.com/gisoracle/p/7628992.html
Copyright © 2011-2022 走看看