Why on Android you can't use lists without adapters?

Has to be perverted so:
// get the instance of ListView
ListView listView = (ListView)findViewById(R. id.listView);

// define a String array
final String[] catNames = new String[] {
 "Ginger", "Barsik", "Murzik" 

// use the data adapter
ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, 
 android.R.layout.simple_list_item_1, catNames);


And this ListView Recycler Pro do not say more code

And I would like:
ListView listView = (ListView)findViewById(R. id.listView);
listView.add("snow leopard");

And the crazy thing is that no one has asked this question and have not done your extends ListView with blackjack and hookers.
Like everywhere it is, Winforms, WPF, Qt and here.
July 8th 19 at 12:10
5 answers
July 8th 19 at 12:12
Why on Android you can't use lists without adapters?

Because Single Responsibility Principle, aka the Single-responsibility Principle. Each class should have one single responsibility. In the above example the ListView is responsible to use the provided widgets in the list view and Adapter is responsible for creating the supplied widgets.

The division of responsibilities leads to the fact that classes become simpler and less error prone when making changes. Select adapter in a separate class makes it relatively quickly to replace its implementation today in order to put your ListView new widgets you need to ArrayAdapter, as you have two dozen items you get from the network, and you can store them in memory, and (exaggerating) tomorrow elements is two thousand and remember to keep not comme Il faut, accordingly, you decide to tie the caching of items in the database, and now you need a CursorAdapter.

Based on the same principle, for example, in Java the responsibility to "keep items" is assigned to the classes that implement the interface Collection, and the responsibility "to sort the items" - on classes that implement the interface Iterator, although it would be possible to dump everything in one pile.
July 8th 19 at 12:14
Without adapter to add any view.
July 8th 19 at 12:16
Your approach is not extensible
July 8th 19 at 12:18
Have you thought about the flexibility of this approach? ListView and RecyclerView and interesting that allow you to add arbitrary list View and implement the elements of Rx.
I think the issue is with trying to use a ListView instead of a Spinner. Each View has its place.
Other media have their own equivalent of the ListView, allowing allowing the use of hierarchy as list items.
July 8th 19 at 12:20
If you add via xml, the elements will automatically be added as a header. In General, for such cases there is a ScrollView as the main objective of the ListView to reuse items.

Find more questions by tags Android