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?
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).
Related
I'm programming a web version for our Android app, which is similar to Instagram. I chose this to create the feed:
<div *ngFor="let post of postList"> ... </div>
Inside that div tag is the HTML of a single post, like the image, the caption etc.
My question is if that is a good choice of architecture. In particular, I'm concerned if this works if the user keeps scrolling to the bottom and the array postList becomes arbitrarily big.
If I understand it correctly, the HTML code of the site will grow arbitrarily big too (for each new post, one clone of that div is appended, right?).
But doesn't that cause performance issues at scale? Coming from Android I know that when you use ListView you will get exactly those performance issues, so you use RecylcerView instead, which recycles views, so no matter how big the array is, you only have a "small" amount of views being used due to the recycling.
How to handle this in web dev? Am I good to go with my solution from above?
Another option you could try if you do not want pagination but want the list to be performant, would be cdkVirtualFor from angular material. With little setup this can turn a large list into something that performs very well.
https://material.angular.io/cdk/scrolling/overview
In short, that will be a problem if you're not limiting the number of results returned. I would recommend researching pagination for limiting query results
Say you've a list of Strings. The number of Strings varies. Is there a way to randomly display these strings like in an Apple presentation when they show a bunch of features in a slide. See link for an example.
http://www.technobuffalo.com/2011/06/10/iphone-5-feature-hinted-at-in-ios-5-wwdc-presentation/
So, text is randomly scattered but never overlaps. Spacing is pretty even. Some text is dim, some is bolder, big, small, etc. I couldn't find the 'name' of this effect (or these multiple combined effects) if there even is one?
I assume they do it manually in a slide of course, but I was wondering if there was a known way of doing this programmatically.
Any help would be much appreciated!
I'm writing one of those reader applications. I would like to know if you have opinions and arguments for and against using WebView and Canvas (with drawText()) to achieve it.
What are the requirements:
format text according to a few html tags: <p>, <strong>, <h3>, <br/>, <a>,
display images within the text (they are in <img> tags),
display the text in two columns on tablet devices,
paging the text (Google currents style)
The ones in bold are absolutely required. The latter are strongly desired, but I can drop them.
So as far as my knowledge goes:
WebView will be great when it comes to displaying the html formatted text. I also don't have to take care of loading images, tey will be loaded automatically with <img> tags (will they, even if I use loadData() instead of loadUrl()?). The problems begin if I try to page the text. Is there a possibility to count the size of the text in a WebView and reflow it into multiple pages (using ViewPager)?
Canvas is great when it comes to counting the size of the text, putting it into columns and pages. But I will have to handle all the HTML tags myself, format the text myself. What is even worse, I will have to extract images' urls, handle the downloading and putting them back to the text (reflowing the whole text every time they load). Am I right?
Can you point some other advantages and disadvantages of using them? Which would you choose? Or maybe something else? Or is there some lib which does at least some of the work for me?
Why not use the Textview combined with spanned text and viewpagers for the paging.
First let me say that I'm very new to android development (although I have a good understanding of the basics of java), and I am building a magazine reader app for a campus publication I work for.
I want to display each article using a ViewPager widget. I'm going to build a java program which enables the magazine editor to post articles in .txt format onto a server, along with images associated with each, and have the android app periodically download these articles to a local folder.
I'm a little confused about how to construct the views for each ViewPager from the text files. Somehow my logic needs to determine the size of the screen running the app, in order to know how many words can fit on each screen.
Is this right, or am I fundamentally misunderstanding ViewPager somehow? If so, how might I structure the program to configure the views dynamically based on the txt + images given to it?
From what I understand, each page will contain as much of the article as possible, and when the user selects the article they will be able to see the entire thing. Something like this, but so it fills up the entire screen?
If this is the case, you have two options here:
Just ellipsize the textview so that it ends with a "..." at the end. Probably the preferred solution.
Resize the TextView to fit all your text (Auto Scale TextView Text to Fit within Bounds).
EDIT:
Here's a different interpretation of your question.
From what I understand, you're trying to have something like an eBook reader with an undefined number of pages; kind of what Flipboard does:
Basically, once all the text fills in the entire area you want to have it continue to the next page.
The easiest way to do this, if you do not need native performance, would be to just use a WebView, split the text across several columns, and have only one column be visible at a time.
However, it is certainly possible to calculate how tall the entire text would be and then split it up accordingly; i.e. Pagination in Android TextView
It seems similar questions have been asked and addressed: Splitting a TextView into multiple TextViews relative to screen height (see the accepted answer).
I am building an application for Android (1.5) that, after quering a webservice, shows to the user a big amount of data that should be displayed in a "grid" or "table" style.
I must show a result of about 7 columns and 50 rows (for example a customer list with names, addresses, telephone number, sales amount last year and so).
Obviously, the 7 columns will not fix in the screen and I would like the user would be able to scroll up/down and LEFT/RIGHT (important because of the number of columns) to explore the grid results.
Cell selection level is NOT necessary, as much I would need row selection level.
What is the best approach to get this interface element? Listview / GridView / TableLayout?
I would suggest a grid with rows that are 'expandable' to show the child row containing a subset of the data that you could maybe consider as details. That way the user can look at data for the rows they are interested in, but ignore the rest.
By the objects you mention it looks like you're talking about .NET. In that case GridView will get your data displaying quickly (least programming) and in the most flexible fashion.
All you have to do is assign your contacts data to the grid view's DataSource member and you're done.
I don't know much about Android GUI programming, but the best approach for me would be using landscape orientation, few rows per page (like 5-10) and paging so that GUI will not get slow.
Check out the SlowAdapter, List13 example in the samples folder.
That might answer your questions.
On my PC the path is
"sdk folder"->android-2.1->samples->ApiDemos->src->com->example->android->apis->view
This 2 dimensional scrollview might be what you're looking for: http://androiddevblog.blogspot.com/2009/12/creating-two-dimensions-scroll-view.html
It is using a TableLayout so for reallly large datasets it might not be optimal because the views won't get re-used on scrolling. But 7x50 does'