Showing posts with label Designer4android Tutorials. Show all posts
Showing posts with label Designer4android Tutorials. Show all posts

TabHost example

Default TabHost example

In this example we will create one layout with a TabHost that fills the entire screen. Using a custom class which you can use in your own project we will add three tabs to the TabHost by loading additional three layout files.
The class is included in the attached zip file.

The first layout (MainLayout) consists of a single TabHost.
Using the following script the TabHost is set to fill the entire available screen:
'All variants script
We also set the NativeClass property to: .ExtendedTabHost
At runtime our class will be instantiated instead of the standard TabHost.

The ExtendedTabHost includes a helper method named extendedAddTab which is useful for adding tabs.
It expects 4 arguments:
- Tab title
- Default bitmap (for the title)
- Selected bitmap (for the title)
- The tab page view.

First program - Hello world

There are two tasks required in order to build the user interface with Designer4android:

- Build the the interface with Designer4android tool.
- Integrate the design in your Java project.

In this simple program we will create a layout made of a single button. Clicking on the button will show a toast message.

When you start D4A tool you will see two forms: The properties grid / script window and the abstract designer:

Installation and configuration

Getting started with Designer4android:

1. Download the trial version or purchase the full version.

2. Inside the zipped file you will find two files: d4a-install.exe and Designer4android.jar.

3. Double click on d4a-install to install Designer4android tool.

4. Designer4android.jar should be added to your Android project. It is done by copying the file to 'libs' folder under your project folder. Create this folder if it doesn't already exist. Right click on the project and choose Refresh to make Eclipse find the new library.