2012-07-25 66 views
-1

关于三星I9003当我滚动视图造成图形噪音。可能是什么问题呢?Android滚动tablelayout造成图形噪音

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

对于从ArrayList中我做每一个元素:

//这里不用像为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+行之后。这种结构对于某些手机来说太复杂了。并使用表格布局和复杂的行与多个textviews和imageviews的少量对这些内容


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

回答

0

并使用表的布局,并与多个textviews和imageviews的少量复杂的行为对这些内容

没有合适的解决方案,因为你描述的,当列表变得太大时会人为增加太多的意见纳入记忆在同一时间。最终,如果您的列表变得足够大,任何设备只会因OutOfMemoryException而崩溃。

实现这种滚动列表的正确模式是使用ListView和自定义的ListAdapter。该模式在屏幕上滚动时回收视图,最大限度地减少内存使用量,而适配器的工作是在滚动查看视图时提供填充每个视图所需的数据结构。