How to add a simple
Alright, this seems like the simplest thing but I can't quite seem how to get it to work…
How do you add a simple "Loading" text label as your App content loads? Like on the first page I have a TableView with rows pulled from a MySQL DB and they take like ~5 seconds to load (Depending on 3G, WiFi, etc.). Right now it just shows a blank screen, then everythig loads. How would I add a "Loading…" with maybe an activity indicator under it that will show up just when the content is loading?
5 Answers
-
Like this?
http://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/activity_indicator.jsShow the activity indicator when your app starts and after you set the data for the table hide it.
-
Yes, but I don't really understand how to get it to show before it loads.
-
First of all, keep in mind that you can't add an activity (loading) indicator to your Default.png that first shows when you launch your app. That's just a static image.
Once your app actually loads, the first thing you should do is show an activity indicator. Create it and add it to your window. Then add an event listener or flag of some kind to your database operations so that when it's done loading, you can hide the loading indicator. There's a lot to do to pull that off, but hopefully that gets you pointed in the right direction.
-
The activity indicator cannot be shown before the splash screen, but only after it.
So in you app.js, first thing to do is to create the activityIndicator and show it ( using the it's method show ). -
For some reason the simulator can't view the ActivityIndicator, it gives me an error. I can't get you the error now, I'll get it in an hour or so.