我必须显示多个图像,所有将在Android上可点击

时间:2013-03-28 06:39:45

标签: android android-listview android-gridview

我在一个库上创建一个Android应用程序,它看起来像这个enter image description here

我需要动态地放置所有这些书,所有这些书都应该在点击一本书后单独点击,它将通过默认的pdf阅读器打开。

我的问题是使用列表视图是否可能,那么什么是合适的方法。并请告诉我一些我找不到的例子。

2 个答案:

答案 0 :(得分:1)

http://code.google.com/p/shelves/。 Romain GUy的一个项目。值得一看项目。

http://code.google.com/p/shelves/source/browse/trunk/Shelves/srchttp://shelves.googlecode.com/svn/trunk/Shelves/。它是只读的。打开主干并复制代码并使用它。

使用gridview。 http://developer.android.com/guide/topics/ui/layout/gridview.html

Universal Image Loadeer。

https://github.com/nostra13/Android-Universal-Image-Loader

它基于Lazy List(基于相同的原理)。但它有很多其他配置。我更喜欢使用Universal Image Loader,它为您提供了更多配置选项。如果下载失败,您可以显示错误图像。可以显示带圆角的图像。可以缓存在光盘或内存上。可压缩图像。

在自定义适配器构造函数

  File cacheDir = StorageUtils.getOwnCacheDirectory(a, "your folder");

  // Get singletone instance of ImageLoader
  imageLoader = ImageLoader.getInstance();
  // Create configuration for ImageLoader (all options are optional)
  ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(a)
  // You can pass your own memory cache implementation
 .discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation
 .discCacheFileNameGenerator(new HashCodeFileNameGenerator())
 .enableLogging()
 .build();
 // Initialize ImageLoader with created configuration. Do it once.
 imageLoader.init(config);
  options = new DisplayImageOptions.Builder()
  .showStubImage(R.drawable.stub_id)//display stub image
  .cacheInMemory()
  .cacheOnDisc()
  .displayer(new RoundedBitmapDisplayer(20))
  .build();

在你的getView()

  ImageView image=(ImageView)vi.findViewById(R.id.imageview); 
  imageLoader.displayImage(imageurl, image,options);//provide imageurl, imageview and options.

您可以配置其他选项以满足您的需求。

除了延迟加载/通用图像加载器,您还可以查看支架以实现平滑滚动和性能。 http://developer.android.com/training/improving-layouts/smooth-scrolling.html

编辑:

https://github.com/androidnerds/shelves。链接下载为zip。

答案 1 :(得分:0)

可以在GridView

中使用

点击此链接 - > Android GridView Layout Tutorial 简单的教程开始