- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在动态创建 Imageview 并显示它。但是我在滚动时遇到了重新加载问题所以我决定使用 NetworkImageView 但在这里我无法设置位图。它没有显示任何错误,但没有显示任何图像。在我的代码下面...
final NetworkImageView imageView = new NetworkImageView(context);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(150,
200);
params.weight = 1;
//imageView.setImageBitmap(null);
imageView.setLayoutParams(params);
imageView.setMaxHeight(200);
imageView.setMaxWidth(150);
// bitmap =//
// BitmapFactory.decodeResource(context.getResources(),R.drawable.ic_menu_folder);
// Log.i("Bitmaps Counts", String.valueOf(pos));
/* comment all this...
new Thread() {
public void run() {
bitmap = downloadImage(tempValues.getItemAbsolutePath());
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
imageView.setImageBitmap(bitmap);
}
});
}
}.start();*/
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
ImageLoader mImageLoader = new ImageLoader(requestQueue,new LruBitmapCache(1000000));
mImageLoader.get(tempValues.getItemAbsolutePath(),
ImageLoader.getImageListener(imageView,
R.android.defaultimg,
R.android.errorimg));
layout.addView(imageView);
下载图片代码..
/* unused method
private Bitmap downloadImage(String url) {
Bitmap bitmap = null;
InputStream stream = null;
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
bmOptions.inSampleSize = 1;
try {
stream = getHttpConnection(url);
bitmap = BitmapFactory.decodeStream(stream, null, bmOptions);
stream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
return bitmap;
}
private InputStream getHttpConnection(String urlString) throws IOException {
InputStream stream = null;
URL url = new URL(urlString);
URLConnection connection = url.openConnection();
try {
HttpURLConnection httpConnection = (HttpURLConnection) connection;
httpConnection.setRequestMethod("GET");
httpConnection.connect();
if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
stream = httpConnection.getInputStream();
}
} catch (Exception ex) {
ex.printStackTrace();
}
return stream;
}*/
错误日志
05-12 19:11:13.971: E/AndroidRuntime(11177): 致命异常: Thread-732505-12 19:11:13.971: E/AndroidRuntime(11177): 进程:com.dar.app,PID:1117705-12 19:11:13.971: E/AndroidRuntime(11177): java.lang.NegativeArraySizeException: -35005-12 19:11:13.971: E/AndroidRuntime (11177): 在 com.android.volley.toolbox.DiskBasedCache.streamToBytes (DiskBasedCache.java:316)05-12 19:11:13.971: E/AndroidRuntime(11177): 在 com.android.volley.toolbox.DiskBasedCache.get(DiskBasedCache.java:117)05-12 19:11:13.971: E/AndroidRuntime(11177): 在 com.android.volley.CacheDispatcher.run(CacheDispatcher.java:100)
最佳答案
you can use volley image downloder
很简单默认 img 已设置...加载程序请求图像 ..如果使用 url 找到图像,它将设置 .. 或者如果错误,它将设置错误图像 .. 这样你就会在加载 img 时通知错误
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
ImageLoader mImageLoader = new ImageLoader(requestQueue,new LruBitmapCache(1000000));
mImageLoader.get(<img-url>,
ImageLoader.getImageListener(<imageview-object>,
R.drawable.defaultimg,
R.drawable.errorimg));
关于android - 将位图设置为 NetworkImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30190823/
我有一个NetworkImageView,它从 URL 加载其内容,但在特定情况下,我还希望能够从用户的图库加载图像(甚至用相机捕获图像) . 我正在使用Image Chooser Library从图
CircularNetworkImageView thumbNail = ((CircularNetworkImageView) convertView.findViewById(R.id.UserI
我正在动态创建 Imageview 并显示它。但是我在滚动时遇到了重新加载问题所以我决定使用 NetworkImageView 但在这里我无法设置位图。它没有显示任何错误,但没有显示任何图像。在我的代
我正在尝试从我的 API 上传图像以将其显示为个人资料图片,问题是从用户第一次打开抽屉导航开始,图像就不会加载,这会使整个布局消失,但是从第二次一切正常,我注意到当图像的宽度小于高度时会发生这种情况。
我正在尝试在 ViewPager 内的 NetworkImageView 上实现缩放和双击功能。我引用了本教程:http://www.androidhive.info/2013/09/android-
我试图从 ListView 中获取 NetworkImageView 的图像路径,但它返回 null。在我的 MainActivity.java 中,我使用以下内容: listView.setO
所以我决定试用新的 Volley library如 Google IO 2013 所示. 我尝试过使用 NetworkImageView 的简单解决方案在 GridView 上显示多个图像。 它运行良
我对这个出色的库怀念的是它不会在 NetworkImageView 中回收位图。如果在方法 NetworkImageView.onDetachedFromWindow 中某处调用回收将是完美的。目前,
有人知道是否可以使用 Google 的 Volley 库从单个 NetworkImageView 中清除缓存的图像吗? 我在 NetworkImageView 中有一张头像图片,我想在将其上传到服务器
我有一个 ListView 显示的东西,其中许多有说明性图像,有些没有。 ViewHolder 使用 NetworkImageView 来显示插图。 问题是即使设置了默认图像,它也不会显示,直到调用
我通过调用 setImageUrl 使用 Volley 的 NetworkImageView: mANetworkImageView.setImageUrl(url, getImageLoader()
我在尝试将 Volley 的 NetworkImageView 与 Google Maps API v2 的 InfoWindow 结合使用时遇到问题。 我的标记显示了一个信息窗口,其中包含从互联网上
我想从资源中设置 NetworkImageView 的图像。 我目前使用的配置是,如果有与内容关联的图片,则图片是从网络上下载的。如果没有图像,则使用预定义的资源。 final NetworkImag
我填充了一个 ListView,其中每行中的一项是 NetworkImageView。现在我通过 Intent putExtra() 将每一行传递给 detail_product Activity 。
我试图在我的应用程序中的 Volley 类的 NetworkImageView 中禁用缓存。我试过这段代码,但它没有删除缓存。 mNetworkImageView = (NetworkImageVie
我使用 Volley NetworkImageView 从互联网下载图像并显示在我的 listview 中。现在我想让 Volley NetworkImageView 在没有可用网络时显示保存的图像。
因此,我将 MVVM、数据绑定(bind)、RecyclerView 和 Volley ImageLoader 与 NetworkImageView 结合使用。 我主要是尝试显示包含 NetworkI
我有一个包含 NetworkImageView 项目的列表,我遇到了一个奇怪的错误。我希望能够使用滑动手势删除列表项,所以我使用了 EnhancedListView图书馆。问题是,当我使用滑动手势删除
我在我的项目中使用了 ViewPager,到目前为止,我发现 Volley 非常擅长为各个页面加载图像。 Volley 需要 com.android.volley.toolbox.NetworkIma
我在我的应用程序中使用 Facebook 照片。 Facebook 照片存储在 https 网址后面。 谁能给我一个使用 https 使用 networkimageview 加载图像的示例? 最佳答案
我是一名优秀的程序员,十分优秀!