Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListActivity vs ListView [closed]

I'm learning android programming, and here is my doubt: I can create a full screen ListView with the ListView object itself, or through a ListActivity.

Is there one that is preferable to the other, whether it be for efficiency reasons, code maintainability, or Android best-practices?

like image 932
Lucas Vieira Avatar asked Jan 13 '23 00:01

Lucas Vieira


1 Answers

If it's fullscreen, it should probably be a ListActivity.

It's not always clear how to divide parts of an app into Activities, but one Activity per screen is pretty common.1 You likely shouldn't be showing a fullscreen ListView over other Views in a single Activity.

Note that ListActivity is just a convenience to save a bit of boilerplate code for a common Activity layout. The layout and IDs are preset, so that you don't have to create them. However, if you were designing an app that included a fullscreen list, but custom Activities (maybe everything subclasses a BaseActivity class that handles checking authorization), there's no harm in making your own Activity with a fullscreen ListView as its layout. (In that case, I'd recommend looking at the features of ListActivity like the empty view as it's more complex than merely a single ListView.)

1. This is actually more complex nowadays because Fragments are the norm and have even fuzzier boundaries, but we'll leave them out of this discussion.

like image 150
blahdiblah Avatar answered Jan 20 '23 23:01

blahdiblah