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?
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.
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