Ejarit Faldoiun
Ejarit Faldoiun

Reputation: 11

Bad Idea to create HTML content in android app?

I'm creating an app that needs to display a table, with say, 30 columns and 30 rows. I want the user to be able to use swiping to move around the table/spreadsheet. The idea is that probably the entire table will not be visible on the screen, and if it is, it will hardly be readable, so there will have to be some max-columns-on-screen value. Each cell in the table must be capable of being a different color than the rest.

So far, I've looked into TableLayout. This doesn't seem to support different colors or swiping... actually, it does support different colors via .xml, but this isn't changeable at run time, and seems like it would be very messy anyway.

WebView looks to be an option, as I am proficient with HTML/CSS but can't find many resources about creating HTML and CSS content on the fly with android - only loading it; although I can imagine writing a file with the data and then loading it, and deleting the file. Not sure if any of this is good performance wise.

What direction should I head, before I start heading in the wrong direction? :-)

Upvotes: 1

Views: 229

Answers (2)

x-code
x-code

Reputation: 3000

Either method can solve the problem, so it's a judgment call based on your goals and requirements.

On the plus side for Android native views:

  • They are pre-compiled and easier to parse than HTML, so they will load faster, scroll more quickly, and require less memory.

  • If you intend to write a lot of Android apps you will need to learn them.

If you took this route, a typical approach to draw multiple columns would be a ViewPager with sliding tabs. See for example the Google Play Store app.

It's not the case that coloring native views dynamically is impossible or messy; it's not hard at all but it takes time to learn how, which brings me to the plus side for HTML/webview:

  • A programmer with expertise in HTML will solve problems faster by just using HTML.

  • Layouts designed in HTML for an Android web view can be re-used on other platforms.

Again, it's not really hard to load dynamic HTML into a web view. There are a few tricks you will need to learn but that's it.

Upvotes: 1

Felipe Silveira
Felipe Silveira

Reputation: 533

Yes, it is possible (and not difficult) to support different colors and gesture in the tablelayout rows.

I think it is always a wiser choice implementing the native components, once it has a better performance and it has a better layout adjust to different android versions.

Upvotes: 1

Related Questions