Managing Reports in Android - android

I have a scenario where I have to show a huge report which consists of about 16 fields, and the last field consists of a radio group. I've taken a Table layout for this. But the problem is, I don't know the size of each field. I mean, there could be 50 characters in one, and 2 in another, and I have to adjust the width and height basing on that without loosing the look and feel criteria. For example,the first column is a Serial No which may contain 4 digits max, the second column contains an ID which may be a 20 digit number and so on. I can use Wrap Content, but its making the page clumsy! So, my question is, is there any possibility that my fields can automatically set their width and height basing on the length of the characters.Thanks in advance! Any help will be appreciated!

Related

Dynamically Increasing numbers in TextView Android

I want to Show numbers that should increase to a particular limit dynamically.
For Example if I get a number 103. Than my textView should show 1 first and than let us say 3 than 6 than similarly increasing to 103 finally. People call it lottery style text display.
Let us say number is in num variable. than numbers should increase from (num-num) to num.
I designed Logics but if number is very large say 1 billion. than increasing/lottery effect takes too much time.
I am looking for an API where I can specify time in which I want the lottery effect to finish and final number that should be there. i guess this clarifies API requirement..
Do we have any API to do it in TextView in android???
You can create simple yet random number logic for it.
Create an array say of size 10 with random numbers eg 1,13,6,8,3,15..
Create random number class that will give you random number between 0 to array length
So you will get any random number within array each time
Create addition variable, which will get incremented with the above number
before showing the number, check if its larger than the original number
if lesser, show the number, if larger, show the original number
You can implement any other logic, but I have sued this logic, so suggested it :)!

Need advice on view layout for Google Glass app - a table with varying # rows which should fill the screen (dynamic text size)

I'm creating a Google Glass app and need to display a simple table. The table will have 2 columns and a varying # of rows.
I'd like the text size to be dynamic based on how many rows are in use. So if you have just 3 rows and the strings in the cells are short (in terms of length) the text size should be larger. If, on the other hand the view updates and now there are 6 rows and/or the string length in the cells is greater, the text size should be reduced.
Plainly put, the text size should be computed so that the text is as large as possible while still fitting the entire table on screen.
Any advice on how to create a layout to achieve this? I found the GridLayout but I think I'll need to dnyamically update it since the # rows can vary. Then there's the text size issue.
This is the kind of problem that is easy on the Web but hard on Android. So one approach might be to put a webview into your app and show an HTML table you generate locally and inject into the webview.
You might have reasons this won't work for you. If you need a more native approach this is a problem that has been solved in native Android apps, basically by measuring the font size to see if it will fit in a space iteratively. You start small and increase the size until it doesn't fit, then use the size before the one that didn't fit.
Here is a thread about that approach:
How to adjust text font size to fit textview
That will adress the difficult issue of text size.
Once that is solved the layouts are easy, many containers will work including GridLayout, TableLayout or even a series of nested LinearLayouts.

in a paragraph how to find the each line's first and last word programmatically in android textview

I want to find the line's first and last word of a paragraph.
sample :
My country is Turkey.I love my country very much.
There are four season in my country in a year. Each
one has 3 month. That's the place where every one
live *in*.
In such a paragraph, I want the words that is in Bold.This paragraph is in textview
and the code must take care of the width of textview.If width changes, first and last words also changes, and algorithm must find them.
If you help, I'll be glad.
I'm not sure how android handles the actual placement of text with resizes and all that. I really doubt that it adds in tab carriages and newlines to the text to display them, but if it does, you could use regex to find that. Or regex with the line anchors. Take a look at this, see if it helps:
http://www.regular-expressions.info/anchors.html

Optimizing the number of views in a layout

one of the fragments used in this app should be a table of mostly numerical data.
6 columns by 15 rows
the top four header rows have some fused cells
that's roughly 90 views (minus the fused cells + the purely layout views - tablelayout, tablerow, for example).
The first problem is a warning that over 80 views is too much, and the app might get laggy.
What can I do about this, considering this fragment/view can't be split? - the user needs access to this table of data all at once.
Secondly, the data in the table is static - and a lot of it is calculable. However different languages don't present numerical data the same way; for example "1,000" in English would be "1000" in French - and would maybe not be represented using roman numerals in some language I don't know.
Should these roughly 30 numerical items go in a /res/values/string_file.xml, considering the file will exist anyways, if only for the table headers, or should the app calculate them, apply a locale filter, and output them to the layout?
Thank you

Two columns of autowrapped text

I need to lay out several (for example, two) labels (textviews) as columns. The texts can be longer altogether than one screen line and may not contain line breaks, so they need to be formatted (wrapped) to fit the screen width.
I can arrange labels as columns if they are shorter altogether than a screen line. I can wrap a text to fit the screen if there’s only one column. But if the texts are longer and there are more than one column, I cannot achieve what I want, because the first column always fills the whole screen width.
I tried to do this via xml-markup. I tried a lot of markups using LinearLayout, TableLayout and RelativeLayout. All didn’t work. Maybe, I didn’t use them properly.
I can imagine the ways using code to manually calculate views’ widths, but haven’t tried. Any solution is welcome, but using markup only are preffered.

Categories

Resources