On samsung I9003 When i scroll the view is causing graphical noise. What could be the problem?
First i read XML file that contains specific structure and i put that structure to arrayList.
For each element from arrayList i Do :
//here goes a small image like 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);
}
After adding 10+ rows like that phone cant handle it . Is this structure too complicated for some phones. And is using table layout and complex rows with multiple textviews and small amount of imageviews is right solution for such content
Well I implemented sackOfViewsAdapter, but it doesnt help. On the same samsung phone application does not work properly. I noticed one thing, if you start application first time after installing it, everything works fine, theres no lag and graphical ‘noise’ on the screen, but when application is forced closed and started again all these wierd things happen
No, because as you described, when the list gets too large you are inflating way too many views into memory at the same time. Eventually, if your list gets large enough, any device will simply crash with an
OutOfMemoryException.The correct pattern for implementing a scrolling list like this is to use
ListViewand a customizedListAdapter. This pattern recycles views as they scroll on screen, minimizing memory usage, and the job of the adapter is to provides the data structure necessary to fill in each view as it scrolls into view.