I am currently working on a ListView that contains around 80 to 100 items (TextViews). I don’t think it is too much content, but when i scroll (with fingers) the ListView is bobbing or laging. However, when I use the “fast-scroll-button” – that thing on the right of the ListView – the scrolling appears very consistent and smooth.
Did anyone have the same problem? I tested the ListView on my HTC Sensation.
Here is my ListView code:
<ListView
android:id="@+id/list_view"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:scrollingCache="true">
</ListView>
And the Java code:
adptr = new ArrayAdapter<String>(iF, R.layout.list_item, showing) {
@Override
public View getView(int position, View convertView, ViewGroup grp) {
LinearLayout lin = new LinearLayout(this.getContext());
lin.setOrientation(LinearLayout.HORIZONTAL);
// Icon
ImageView v = new ImageView(this.getContext());
// v.setBackgroundDrawable(iF.getResources().getDrawable(R.drawable.cube_icon));
// Text
TextView txt = new TextView(this.getContext());
txt.setTextSize(Float.valueOf(prefs.getString("pref_txtSize", "12")));
txt.setPadding(10, 10, 10, 10);
txt.setText(this.getItem(position));
txt.setTextColor(getLineColor(position));
// Shortcut
LinearLayout shortLin = new LinearLayout(this.getContext());
shortLin.setGravity(Gravity.RIGHT);
LayoutParams par = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
shortLin.setLayoutParams(par);
TextView s = new TextView(this.getContext());
s.setTextSize(Float.valueOf(prefs.getString("pref_txtSize", "12")));
s.setWidth(iF.getResources().getDimensionPixelSize(R.dimen.shortcutWidth));
s.setPadding(10, 10, 10, 10);
s.setText(getShortcut(position));
shortLin.addView(s);
// Return
txt.invalidate();
v.invalidate();
s.invalidate();
lin.addView(v);
lin.addView(txt);
lin.addView(shortLin);
return lin;
}
};
As you can see, I made a customized ListView. The ArrayAdapter will be added in a different method (not shown here).
Thanks in advance
Adrian
Do you remember about cache?
and
?