Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListView vs LinearLayout

I'm writing a horizontal tv-view, similar to the ones you know form tivo systems and similar. For each channel there is a row with the programmes for the next 6 hours or so, with a width proportional with their play time.

My idea is to write a custom widget for each row, and stack these on top of each other. This should allow me to load the data incrementally, rather than using one big custom view. I will however still need forward/backward buttons at the top of the page that update all rows when clicked.

Now I'm unsure whether I should place these Views in a ListView or a LinearLayout.

I have collected the following pros and cons:

  • ListView
    • Pros
      • Memory efficient - Recycles hidden Views
      • Seems to be used by everyone, in the Android community, for anything.
      • It might be easier to make it lazy, when updating the rows, and thus require less CPU.
    • Cons
      • Overkill - I won't be using most of the features it has to offer
      • It may be slightly more difficult to attach the clickListeners.
  • LinearLayout
    • Pros
      • Simple to use. Does what you'd expect.
    • Cons
      • I haven't seen it used anywhere for long lists.
      • Perhaps it is slower?

The "Seems to be used by everyone" argument for ListView also includes the "Master" Twitter app, which Google uses to show off "Good Android design". They also don't seem to be using most of its features.

Do you have any experience with this kind of work? Are there any recommendations I've missed when reading through the docs?

like image 371
Thomas Ahle Avatar asked Aug 14 '10 14:08

Thomas Ahle


People also ask

What is linearlayout in Android?

LinearLayout is a type of view group which is responsible for holding views in it either Horizontally or vertically. It is a type of Layout where one can arrange groups either Horizontally or Vertically.

What is the difference between listview and WebView in Android?

In android, WebView is a browser that is used to display the web pages as a part of our activity layout. To know more about Web View in android check this, Android WebView with Examples. In android, ListView is a ViewGroup which is used to display scrollable single column list of items.

What is the difference between listview and collectionview and stacklayout?

The Bindable StackLayout is super smooth with almost no laggs, while the collectionview and the listview are almost the same. Regarding iOS i use an iPhone 6.The CollectionView is super laggy on it. The ListView and the bindable stacklayout are both smooth. On newer iPhones the collectionview runs smoothly too.

How to define a layout in an XML file using linearlayout?

Following is the example of defining a layout in an XML file ( activity_main.xml) using LinearLayout to hold a TextView , EditText , and Button. We need to create a layout files in /res/layout project directory, then only the layout files will compile properly.


2 Answers

That schedule looks similar to the Google IO 2010 app. You can checkout their code and see how they have done it.

like image 176
Macarse Avatar answered Oct 26 '22 00:10

Macarse


I ended up using a custom widget. I still don't know which of the mentioned is most effective though.

like image 42
Thomas Ahle Avatar answered Oct 26 '22 00:10

Thomas Ahle