android中,网上的图,如何在界面中显示,在线等 有一图,是网上的 http://0791.8ff.cn/upload/colorful/2012-01/201201310912572359384.jpg现需:1 如何在界面中显示此图 2 android手机上大 中 小分辩率,对于此图如何用大 中小 图呢 3 如何把此图存到本地,再给界面用呢thanks 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class Activity01 extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView iv= (ImageView) findViewById(R.id.ImageView01); iv.setImageBitmap(GetNetBitmap("http://0791.8ff.cn/upload/colorful/2012-01/201201310912572359384.jpg")); } public Bitmap GetNetBitmap(String url) { URL imagUrl=null; Bitmap bitMap=null; try { imagUrl= new URL(url); HttpURLConnection conn= (HttpURLConnection) imagUrl.openConnection(); //将得到的数据转换成InputStream; InputStream is=conn.getInputStream(); //将InputStream转换成BitMap bitMap = BitmapFactory.decodeStream(is); is.close(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return bitMap; }}记得开通访问网络的权限<uses-permission android:name="android.permission.INTERNET"></uses-permission>别忘了给分 关于MP3音乐节拍检测的问题 加载网络图片时如何都能预先能知道他的宽高 电子书阅读器页面排版问题 android中CursorAdapter的bindview调用 有什么方法能实现APK的静默卸载吗? android 手机 菜单列表 中英文混排如何实现? android 高难度UI设计问题!!!! 怎么实现类似360手机助手下载管理的界面 来只菜鸟…………求 求助:android提取系统settings代码怎么单步调试? 菜鸟提问~ Open quote is expected for attribute "android:name" 是什么错误?
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView iv= (ImageView) findViewById(R.id.ImageView01);
iv.setImageBitmap(GetNetBitmap("http://0791.8ff.cn/upload/colorful/2012-01/201201310912572359384.jpg
"));
}
public Bitmap GetNetBitmap(String url)
{
URL imagUrl=null;
Bitmap bitMap=null;
try
{
imagUrl= new URL(url);
HttpURLConnection conn= (HttpURLConnection) imagUrl.openConnection();
//将得到的数据转换成InputStream;
InputStream is=conn.getInputStream();
//将InputStream转换成BitMap
bitMap = BitmapFactory.decodeStream(is);
is.close();
}
catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return bitMap;
}
}
记得开通访问网络的权限
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
别忘了给分