-1

在三星 I9003 上,当我滚动视图时,会导致图形噪音。可能是什么问题呢?

首先,我读取包含特定结构的 XML 文件,然后将该结构放入 arrayList。

对于 arrayList i Do 中的每个元素:

//这里有一个小图像,如 5px * 10px

tr = new TableRow(this);
ImageView triangle = new ImageView(this);

params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
                params.gravity = 0x11;
                params.span = 8;


triangle.setBackgroundResource(R.drawable.complex_grey_down);
                triangle.setLayoutParams(params);
                tr.addView(triangle);
                tl.addView(tr, params);
                // here goes main title of the row
                tr = new TableRow(this);
                child = new TextView(this);
                child.setText(sn.getName());
                params = new LayoutParams(LayoutParams.FILL_PARENT,
                    LayoutParams.FILL_PARENT);
                params.gravity = 0x11;
                params.span = 8;
                child.setTypeface(null, Typeface.BOLD);
                child.setTextColor(res.getColor(R.color.text));
                child.setLayoutParams(params);
                tr.addView(child);
                tl.addView(tr, params);
                // here goes short note under the title
                if (sn.getNote().length() > 0) {
                    tr = new TableRow(this);
                    child = new TextView(this);
                    child.setText(sn.getNote());
                    child.setTextSize(12);
                    child.setPadding(30, 5, 30, 10);
                    child.setTextColor(res.getColor(R.color.text));
                    child.setGravity(Gravity.CENTER);
                    params = new LayoutParams(LayoutParams.FILL_PARENT,
                        LayoutParams.FILL_PARENT);
                    params.gravity = 0x11;
                    params.span = 8;
                    child.setLayoutParams(params);
                    tr.addView(child);
                    }
                    tl.addView(tr, params);
                }

添加 10 多行后,该手机无法处理它。对于某些手机来说,这种结构是否过于复杂。并且使用具有多个文本视图和少量图像视图的表格布局和复杂行是此类内容的正确解决方案


好吧,我实现了 sackOfViewsAdapter,但它没有帮助。在同一三星手机应用程序无法正常工作。我注意到一件事,如果您在安装后第一次启动应用程序,一切正常,屏幕上没有延迟和图形“噪音”,但是当应用程序被强制关闭并重新启动时,所有这些奇怪的事情都会发生

4

1 回答 1

0

并且使用具有多个文本视图和少量图像视图的表格布局和复杂行是此类内容的正确解决方案

不,因为正如您所描述的,当列表变得太大时,您会同时将太多视图膨胀到内存中。最终,如果您的列表变得足够大,任何设备都会简单地以OutOfMemoryException.

实现这样的滚动列表的正确模式是使用ListView自定义的ListAdapter. 这种模式在视图在屏幕上滚动时回收视图,最大限度地减少内存使用,适配器的工作是提供必要的数据结构,以便在每个视图滚动进入视图时填充它。

于 2012-07-25T15:33:25.230 回答