画廊小部件的替代品

发布于 2024-12-11 03:59:48 字数 945 浏览 0 评论 0原文

Android 中是否有比 Gallery 小部件更快的替代方案,因为 Gallery 太慢且滞后,我尝试使用视图持有者来重用视图,但没有结果。我用了经典的方法

public View getView(int position, View convertView, ViewGroup parent) {


        ViewHolder holder;
         if (convertView == null) {
                convertView = mInflater.inflate(R.layout.image, null);

                // Creates a ViewHolder and store references to the two children views
                // we want to bind data to.
                holder = new ViewHolder();

                holder.icon = (ImageView) convertView.findViewById(R.id.ImageView01);

                convertView.setTag(holder);
         } else {
                // Get the ViewHolder back to get fast access to the TextView
                // and the ImageView.
                holder = (ViewHolder) convertView.getTag();
            }
         holder.icon.setImageDrawable(getPicture(items[position]));
         return convertView;

         }

Is there any faster alternative to Gallery widget in Android, because Gallery is so slow and lagging, i tryed to use view holder to reuse views, but without result. i used classic method

public View getView(int position, View convertView, ViewGroup parent) {


        ViewHolder holder;
         if (convertView == null) {
                convertView = mInflater.inflate(R.layout.image, null);

                // Creates a ViewHolder and store references to the two children views
                // we want to bind data to.
                holder = new ViewHolder();

                holder.icon = (ImageView) convertView.findViewById(R.id.ImageView01);

                convertView.setTag(holder);
         } else {
                // Get the ViewHolder back to get fast access to the TextView
                // and the ImageView.
                holder = (ViewHolder) convertView.getTag();
            }
         holder.icon.setImageDrawable(getPicture(items[position]));
         return convertView;

         }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人事已非 2024-12-18 03:59:48

这是其他人创建的几个不同的画廊,并上传到 GitHub。您可能需要检查它们以了解它们的情况以及它们的速度有多快。

This is a couple of various galleries created by other and uploaded to GitHub. You might need to checkout them to see how they are and how fast they are.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文