How to create TV Guide View in Android - android

I'm building an Android app, which will display TV channels schedule.
The view would go something like, the tv guide we view on Tata sky, dish tv or any other service provider, like below:
Table with channel names.
Channel program names in a row, with time defined above, as column header..
Any idea, on how to start with creating this view in Android?
This would be like table with nequal cell widths, connected with time slots above.
Any help would be appreciated.

A possible solution could be to create a custom view that would represent each cell in the TV guide. The cells would need to be defined as focusable and selectable. You would need to decide how many pixels would represent a minute. Say 4 pixels per minute. You'd then calculate a layout width based on (4px per minute x runtime in minutes). Each cell could be added to a linear layout that represents the row. Your 'grid' would be a collection of these horizontal rows.
One caveat about this method is memory usage, you wouldn't have the automatic view recycling that you get in RecyclerView so would need to take care of that manually.

Related

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.

ListView performance with complex views as list items

I had ran into problem with performance. I have to develop complex ui based on ListView and really complex item layout contained nested layouts, custom views, lot of images etc.
The problem is as usual, when client is creative and has no limit credit card: performance.
Creating of list view lasts ~10 seconds on fast device.
When I profiled application, I discovered, that most of the CPU power is used for onMeasure method - you know how it works - measuring of the width, passing measure demand to children, getting them into lauouts, asking layouts to change it's height, then measure once again with new bounds - horror.
I can't show you the screen with the layout - just say that there is ~80 views in each item - no we can't do less.
My idea is based on simple observation - every single one sub view on particular device has this same size - i.e. if I have an image view to display inside the list item - on each item it will have exactly this same size.
So I want to make some cache for dimensions - i.e. - I have LinearLayout containing bunch of views, I want to perform simple algorithm:
Create CustomLayuout extending LineraLayout
put members like width, height (i.e. static)
when view is created for a first time I want to get it's size put it into static vars and reuse them when next instance of the view will be created.
After this (a bit long) description finally my questions:
Can I apply approach like that, or there are some serious
disadvantages?
How to do it (code sniplets welcomed)?
Thank you in advance

How can i programmatically implement a special viewgroup that has buttons and support swipe

I want to implement a viewgroup that acting like the launcher application. It can be as width and height that i specified and it has the column and row size properties and has to provide paging. For example:
for one usage, say, i want to put screen 30 buttons. i want these buttons within a (w200dip h40dip) sized horizontal scroller. scroller has to paging support. and say, on each page i want 12 buttons (6 columns 2 rows).
(the image below)
haw can i implement this, thanks for every little help :)

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

Best approach to show big amount of "grid" data in Android

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'

Categories

Resources