Is there a way to use a Flex Mobile List control like a ASP.NET repeater?
For example a repeater in ASP.NET allows you to have many controls in the itemtemplate that can be bound to a data source. A easier way to understand it is using the Facebook mobile application. I'm wondering how that is created because I can't seem to use a grid or a list to function in that way.
Although I have never used ASP.NET repeaters, I believe you are referring to an ItemRenderer. Each item in the list will display differently, depending on the data provided to it. You can write your own ItemRenderer in either ActionScript or MXML. If you have large and/or complex data in the list, I would recommend using ActionScript. They can be a little tricky at first, but you will get the hang of it. Start out small. Try simply extending a LabelItemRenderer and setting the text value based on the the data object, then expand it from there. Be sure to take a look at some of the great documentation for it here, and here.
Related
I would like to display some information from a Firebase database on the screen of my Nest Hub.
Let's say I want to scroll through 10 items and display their details every 5s.
If I am not wrong, I am tied to only 2 possibilities
Assistant Actions
I read the doc and made some POC, but it seems overcompliacted, I have to create a project, that I cannot deploy publicly, create a Firebase function to create the webhook, and I don't really have complex Assistant commands to send, so it seems overcomplicated at first sight.
=> Maybe I missed a way to make that simple?
Cast SDK
As an Android dev familiar with Java and now Kotlin, this seems easier, but as far as I understand, I can only cast Media to the Nest. Should I then create a layout with all my info, turn them to image files, and finally create a slideshow for the Nest Hub?
Thanks for any advise
Part of this answer depends on your use-case. Creating an Action via Actions Builder would give you a fair amount of flexibility over the interaction model, as it will support voice commands and you'd be able to trigger it directly from the device ("Talk to X").
Creating something via Cast may be easier, as you're just projecting content (a webview). While easier, you'd need to be able to start it from another device and can't control it with voice. Control can be done through the casting device.
Based on the use-case you've given, as a passive display, I would suggest going with the Cast SDK. You can look at implementing a custom web receiver to manage your web app.
What is the intuition behind views and adapters in Android, that means from where did the person who made this concept get the thought process necessary to create these elements? To elaborate, the concept of circle originated from nature, moon sun such celestial bodies, like wise what is the intuition behind using listview and adapters?
As you probably already know, using ListView (and more recently, RecyclerView) on Android requires the use of an Adapter to get the data from the data source and turn it into something displayable which can then then be shown in the list.
So why did the engineers at Google implement ListView and the backing Adapters the way they did ?
It essentially comes to a few things:
Performance:
Imagine you have 1000 contacts, each with a picture and various pieces of information. You want it to work well, load quickly, and scroll smoothly. The naive way of doing this might be to create a scrollable layout to hold the contacts list, and then simply add a sub-layout for each contact. Unfortunately, this will fail all three requirements: It won't work well, as there won't be enough memory (ram) for all those contacts and especially the associated pictures, and the app will run out of memory and crash; It won't load quickly, as all the contacts and the contact pictures have to be loaded into memory before the list can be shown, which will take a long time; And it won't scroll smoothly because you don't have all of the advanced caching, pre-rendering, and bitmap texture caching that ListView and the adapter does. Use a ListView and an Adapter, and it solves all these problems for you.
Adaptability and ease of use for developers: ListView and Adapters are used for lots of different things, from contacts lists all the way to to complex pages with different answers, comments, and tons of other information in the Stack Exchange Android app. Adapters make working with data from different sources easy: there's a single, common API, which can be used and extended to display any kind of data, much more easily than if every developer had to implement their own solution. Want to load more data when the user has scrolled to the bottom of your list ? Sure, it's easy. Want to have different kinds of items in your list ? Sure, It's really easy.
So, did Google and the Android developers and engineers invent this idea of using adapters ? No.
In fact almost every system or environment which involves showing a list of items uses something similar: The actual list of items, an Adapter behind it, to transform the data and make it displayable, and then the actual data source, which can be anything which gives a list of items, from a database to a web service. It's essentially this: data source > adapter > list where it's displayed. This kind of pattern is used in desktop Windows applications, on iOS, web applications, so the Google engineers took this concept and adapted it to Android.
That's why ListView and Adapters work (and are used) the way they do.
PS: here's a Google IO video by the Google engineers on how to use ListView and Adapters correctly, and a little bit on how they work under the hood: http://youtube.com/watch?v=wDBM6wVEO70.
As a beginner wanting to become more familiar with the android platform, I wanted to create a web client for a website.
Something similar to https://play.google.com/store/apps/details?id=com.krinsen.javadocreader&hl=en
However, I am confused about how the author created the custom UI for the java docs.
To my understanding, there are 2 ways to do this.
One approach is with WebViews. I quickly prototyped a sample of this but I believe (correct me if I'm wrong) that I can't change the UI of the WebView and will have to view the page from the perspective of a browser. Unfortunately, this does not look very well as the website was not mobile optimized and there are inconsistent spacings and odd whitespace.
The second approach is to manually create each View using the different layouts provided by android (LinearLayout, TableLayout, etc). This should create a more custom mobile experience as I can manually construct how each page will look. However, this seems time-consuming as I will need to manually create a different UI page for each page of the website. Also I am confused as to how to pull the data from the website as each new view in the new UI will need the content from the website. Do I need to do HTML parsing to pull the content or is there a better way in the android sdk? What is a good approach that android developers take to extract the different forms of content from a website to redisplay on a android client?
Finally, since I have a very beginner understanding of this situation, am I correct in assuming that most likely the creator of the application mentioned above did something similar to the second approach I mentioned?
What is a good approach that android developers take to extract the different forms of content from a website to redisplay on a android client?
I think the best way is to provide an API for native application. Parsing HTML might look nice untill you need to suppport every change in your HTML page. But if you are not the owner of web-site there is no other choise if only you don't contact owners and ask for an API.
I have android application that is written "regular" way. layouts, java, APK.
Now, depending on some factors I want data to be presented differently to different users with different preferences, etc. Doing it using XML layouts will be very problematic in couple of reasons:
Upgrade issue - we have bunch of users and they not good at upgrading.
Hard to maintain and code.
So, I'm toying with idea of "templates" where we can serve templates from server and just use device to generate those.
Web app won't work because our data available offline in case there is no connection.
There is buttons and stuff that user can press to call regular Activities and do things.
I envision something like:
HTML 5 template with {tags} that I will populate from data. I will receive tempaltes and data separately from server. I will merge that data and display on UI.
Now my question is how do I:
Display HTML5 inside Activity
Intercept button push in HTML in my Java code?
Is this bad idea to write something like this?
It sounds reasonable to me. You can use a WebView for displaying the content. Your app can manage a cache of downloaded templates and other content and display it in the web view either from the web site or from the cache if offline.
I think your objections to layouts are offbase. You really might be better off with layouts. Here's why:
Your app can be set to auto-update by users if you do not change permissions. But pushing updates to your app will remain an issue unless your app is entirely web-based. (not a bad approach by the way) But so long as you have a native app, you will need to push updates from time to time.
And as far as being hard to maintain and code, layouts are specifically designed to make this type of customization manageable. You can break pieces of the layout common to different settings into separate files, and add them with includes.
You can use fragments to adapt to a variety of form factors.
You can serve up different layout based on screen size, language, orientation, or any of a wide variety of variables.
Check out some of the series on layout tricks, and get more familiar with being a layout power user. I think in the long run it will save you a lot of effort, assuming you don't switch to making your app a web app instead.
http://android-developers.blogspot.com/2009/02/android-layout-tricks-2-reusing-layouts.html
http://developer.android.com/resources/articles/layout-tricks-merge.html
http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html
http://www.curious-creature.org/2009/03/16/android-layout-tricks-4-optimize-part-2/
Google: Android Layout Tricks.
Great stuff.
Another benefit: Compiler checking. No broken functionality because a variable or field has the wrong name. Not the case with HTML.
Another benefit: works offline too with no messing around.
And last - you will have a non-trivial amount of work attempting to get this hybrid HTML stuff working the way you want, and then have a very unusual and custom code base that nobody here on Stack Overflow will be able to help you with. Stick with Layouts and there are lots of experts who can help you tackle the stickiest layout puzzles.
I want to make an app for android that updates via the internet so the information in the app is always current. What is the best way to implement this?
I understand I will need the information stored somewhere?
And I will need to be able to access it and read it into the app?
I am not looking for specific code so much as a general way this could be implemented.
As an example think of a weather app that must pull weather data from an online source.
Thanks
In general you could achieve what you want in one of the following ways (both are popular methods and used in many apps):
Implement a web service layer to pull the data from the server back to your application. In Android, this is normally done via JSON based REST API. JSON is used nowadays as the data is regarded more compact that XML and it's easier to deal and manipulate in Android.
Note that it's common to implement caching in phone local storage if the data is not updated frequently.
Most of the time, the authoritative data is stored in the server
With this method, you could arrange the layout freely on your app. However, you need to write Java code to arrange the layout
You could also add better interactivity especially if you are thinking that your UI will have a lot of touch interfaces or animation
Other way you could do this is by developing a mobile HTML webpage that you could embed in Android via Webview. A simple tutorial is available on Android's website
This method will retrieve HTML from the server, the same way your desktop browser retrieves HTML. The only difference is that the HTML is mobile optimized. Good example of mobile optimized HTML is gMail from Google
Using this method, unless you have full control of the server side, you don't necessary can control the layout as the server is the one that generates the HTML
A lot of times that interactivity is reduced with this approach though Javascript framework such as Sencha and others are quickly reducing the interactivity gap between native code (#1) and using HTML