1

I'm currently working on an android application and I recently came across something which mentioned that an activity should aim to have less than 80 views.

I have a couple tablelayouts with some textviews in each one. Would it be more efficient/possible to have one textview and use html tables to try and achieve the same look I have with the tablelayouts?

It would cut down on the number of views, but would it be worth the time to rework the layout?

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
user1496741
  • 97
  • 1
  • 11

1 Answers1

3

To get a Spannable-object (which can be displayed in a TextView) form an HTML snipped, you can use the HTML-class from the Android framework, as illustrated here: How to display HTML in TextView?

However, the docs for this class also state that:

This class processes HTML strings into displayable styled text. Not all HTML tags are supported.

A nice list of supported tags can be found in this answer and this Blog-Post (Spoiler: <table> is not supported).


Theoretically, having more than 80 views on one Activity is a lot. In pratice, it turns out that this can be handled by many phones with ease.

I created an application that collected Geo-Data and displayed all taken locations in a table (which would have more than 900 items). Even with the full table it scrolls smoothly (on my Motorola Xoom and my HTC Desire HD).


If you should encounter any problems with long lists/tables on certain devices, there is always the option of lazy loading.

It should be a general goal to show the most important/precise data at the top (so the user does not need to scroll at all).

So, you would show the lets say 30 best hits and when the user has scrolled down to number 20 (or so), you asynchronously load the next 30 entries. That way, you get a never ending list (given that the data is endless).

Community
  • 1
  • 1
Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111