Posts Tagged ‘XML’

Unity and Android: Create an Unity app with a custom layout

Click here to read Unity and Android: Create an Unity app with a custom layout

Although Android and Unity3D are both common topics here at 41post.com, this tutorial is the first one featured in this website to combine those two topics into a single post.

So, this first Unity/Android post is going to show how to create an Unity Android application that uses a custom layout which makes the Unity View to take up only part of the screen. Additionally, this post shows how to have some Android buttons underneath that View and how to make them interact with Unity. And as a simple example, those buttons will determine which direction the camera should rotate around a blue box. As usual, there’s a sample project is available at the end of the post. Here’s a GIF illustrating how the application looks and behaves:

This is what this post is trying to achieve

The View used by Unity only takes part of the screen. The three buttons are native Android UI buttons.

(more…)

Android: hexadecimal color input using an EditText

Click here to read Android: hexadecimal color input using an EditText

This Android programming tutorial shows how to create a simple application that takes the value of a hexadecimal color at an EditText field and displays it as an ImageView. In order to do so, this post goes into detail on how to correctly parse the EditText String as 32 bit hexadecimal Integer. Additionally, it explains the part of the code that constrains the characters between A to F and 0 to 9 at the EditText. Finally, it tries to solve some of the EditText problems when applying these constrains.

The application in this post has been tested on Android 2.1, 2.3 and 4.0.

So, here’s a screenshot of the example project application in action:

Hexadecimal Color Input

A screenshot of the example project. It’s available for download at the end of the post.

(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: Creating a WebView dialog

Click here to read Android: Creating a WebView dialog

This Android post shows how to display a WebView inside a Dialog, that renders a website to the user. Since the WebView can load just about any web page, it’s possible to provide any information to users without launching the web browser, so they never have to leave the application.

For this tutorial, all code had been developed and tested in Android 2.1, both on an emulator and on a real device. As usual, an example application with the code featured in this tutorial is available for download at the end of the post.

The first thing required to place a WebView inside a dialog is to create a custom Dialog. After that, a WebView can be added to it. The easiest way to do that is to create a new Android layout file (in Eclipse, just right click the Project folder and select New -> Android XML file). Then, add the following code: (more…)

Page 1 of 3123