Posts Tagged ‘Class’

Unity: animated ellipsis

Click here to read Unity: animated ellipsis

We have all seen it on loading screens of a variety of games and applications. I’m talking about animated ellipses, the animated three dots () on the end of a sentence which indicates that the game or software is being loaded.

This post explains how to make exactly that, an animated ellipsis in Unity. Here’s a video showing what the script on this post will do:

(more…)

Android: get String resource at another XML namespace

Click here to read Android: get String resource at another XML namespace

This post shows the necessary steps to obtain the correct String resource outside the Android XML namespace. It has been written specifically for dealing with string resources associated with Preferences inflated from XML files, so this post assumes that the reader is familiar with writing customized preferences for Android. Altought, it can probably be used on other situations. This code has been tested on an emulator running Android 2.1 and also on real devices running Android 2.1, 2.2 and 4.0.4.

(more…)

Android: “reset to default” preference dialog

Click here to read Android: “reset to default” preference dialog

This post explains how to create a DialogPreference that allows the user to reset all preference values to their defaults. This post has been created and tested in both the emulator and on a real device running Android 2.1. Therefore, some method calls used in this example may be deprecated on newer Android versions.

The best way to show how to reset all the preference values with a DialogPreference is by presenting an example featuring PreferenceActivity that sets some preferences, and them show how to revert them back to their default. This example project can be downloaded at the end of the post. So, the first thing needed for this example is a XML file that defines the contents of the preference screen: (more…)

Android: how to rotate a View element

Click here to read Android: how to rotate a View element

Another Android programming tutorial, this time, explaining how to rotate a View element using two distinct approaches. Not only that, but this post also presents a brief explanation on the advantages and disadvantages of each approach. The code featured here has been tested on both the emulator and on a real device running Android 2.1 . Before going any further, please bear in mind that from Android 3.0 (API level 11), a setRotation() method has been added to the View class, therefore, it should be used instead of the code described in this article, which focuses on lower level APIs.

The first and perhaps most direct method of rotating a View element is to create a class that inherits from a View widget that needs to be rotated, for example, the TextView or the Button. Then, inside this class, the onDraw() method must be overridden. (more…)

Android: Creating a two color LED notification

Click here to read Android: Creating a two color LED notification

Another programming tutorial, this time, showing how to make the built-in notification LED on a Android device continuously alternate between two colors. That said, by the time this article is being written, it’s recommended to try this code on a real Android device that has a notification LED instead of running the application on the emulator. Also, the Activity featured below has been created to work on devices with Android 2.0 or later. All code featured in this article is available for download at the end of the post.

To continuously change the colors of the LED, it’s necessary to create and initialize a Notification object that changes the LED colors and post this notification using a handle to the system’s notification service (using a instance of the NotificationManager class). The notification is then canceled, its LED color is changed and the notification is posted again and the process is repeated over and over making the colors swap back and forth. (more…)

Page 1 of 512345