ListView and ListActivity
As described in Google's documentation (http://developer.android.com/guide/topics/ui/layout/listview.html), a ListView
element is a view group that displays a list of items and enables scrolling if the items do not fit the size of the ListView
element. In this section, we will build a simple ListView
element—introducing adapters briefly (we will cover them in more depth in the next section) but we will not spend much time on the ListView
element, as we will favor the use of the newer RecyclerView
element instead in later sections. Using RecyclerView
over ListView
is highly recommended as it is more flexible and does not leave performance improvements optional. ListActivity
is like a normal activity, but with only one single element on it: ListView
.
ListView
Let's begin, first of all, with the ListView
element. Adding ListView
is straightforward; just add it to an existing layout or view group and it will appear in the preview view, as shown in the following screenshot...