I'm trying to create a simple widget displaying football scores updated from the Internet. My biggest problem so far is how to display tabular data in the widget? I want basically to display scores in lines with 3 fixed width columns in each: 1st name of the first team, aligned to right, 2nd current score, centered, 3rd name of the second team, aligned to left.
I was hoping to use programatically created TableLayout or WebView with properly formatted HTML but neither of these methods can be used in widgets. What would be the best approach to this task?
Related
I have a very simple requirement where I need a screen divided into two pieces where the first half is used to input data and the other is to display results based on the input (very similar to frames in browsers). the first half will remain static and will never change.
Is there a way to do it without using fragments and just by using layouts ?
As mentioned by m0skit0 just divide the screen by two with a layout and put the static part on one side and for example a WebView on the other side that you update with the content you want to show (or any other view of course).
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'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).
what I want is exactly what ThinkFree Office pdf viewer Reading View does.
I have a bunch of text and I want to be able to adjust it's size (users can choose from different zooms) and the text should paginate accordingly, I want it to wrap the screen, so that the user doesn't have to 'move' the screen, the rest of the text will show on the next page.
I know how pagination works, but how can I determine how much text has fitted the screen, so I know what to show on the next page?
Thank you
I mean't that you could adapt the codebase there by turning off the resizing part and just using it to paginate. It definitely would need work to make it fit this problem. Did you find a solution?
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'