Android中常用功能总结

1、从网络获取Drawable,此方法需要放在子线程中调用

 /**
     * 获取Drawable,此方法需放在子线程中调用
     * @param url 图片url链接地址
     * @return Drawable对象
     */
    private Drawable getDrawableFromUrl(final String url) {
        Drawable drawable = null;
        try {
            InputStream inputStream = new URL(url).openStream();
            drawable = Drawable.createFromStream(inputStream, null);
            inputStream.close();
        } catch (MalformedURLException ex) {
        } catch (IOException ex) {
        }
        return drawable;
    }

你可能感兴趣的:(android基本控件)