When inflating views for a listView, is it better to have all textViews without android:text in the .xml file and how much does that affects the speed? What about ViewStubs, would that be even faster?
When inflating a LinearLayout with 8 textViews without android:text and with android:text="@string/abc", does that change anything ? note that i am reusing views, so maybe only 10 get inflated and then reused i don't know.
I am developing on a ZTE Blade, so that'a single 600Mhz CPU and not a quad core ...
Simple answer: You should use RecyclerView in a situation where you want to show a lot of items, and the number of them is dynamic. ListView should only be used when the number of items is always the same and is limited to the screen size.
It's more efficient by default, the layout is separated and we have more possibilities over the data set inside the adapter. The ViewHolder pattern allows us to make our list scrolling act smoothly.
You can try this, not sure if it will speed up, but give it a shot.
Inflate the layout in a background thread.
View getView(int position, View convertView, ...) {
View v;
if (convertView == null) {
Start a background thread to inflate your linearLayout.
Pass item data and view 'v' to it.
v = inflate a simple dummy textview;
return v;
}
set normal stuff to convertview here.
return convertView ;
}
In the background thread,
'v'
Then invalidate the view v
.
v.postInvalidate();
This is quite helpful when speeding up list views, especially the View Holder bit: http://developer.android.com/training/improving-layouts/smooth-scrolling.html
I've got a ZTE Blade too, they're slow, but apps that run well on it run amazing on 'normal' phones :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With