The Hierarchy Viewer application allows you to debug and optimize your user interface. It provides a visual representation of the layout's View hierarchy (the Layout View) and a magnified inspector of the display (the Pixel Perfect View).

To get the Hierarchy Viewer started:

1. Connect your device or launch an emulator.2. From a terminal, launch hierarchyviewer from your SDK /tools directory.3. In the window that opens, you'll see a list of Devices. When a device is selected, a list of currently active Windows is displayed on the right. The "focused window" is the window currently in the foreground, and also the default window loaded if you do not select another.4. Select the window that you'd like to inspect and click Load View Hierarchy. The Layout View will be loaded. You can then load the Pixel Perfect View by clicking the second icon at the bottom-left of the window.

If you've navigated to a different window on the device, press Refresh Windows to refresh the list of available windows on the right.

--------------------------------------------------------------------Little bit advice:- Set a break point inside getView(), you can know more on the operation of getView, such as when it will be called, and when go to initialize attributes, or load the previous convertView.

- Modify onItemClick() to check the value of arg0, arg1, arg2 & arg3.

In my code, the object ID of the clicked item of the GridView will be displayed on the Toast, in decimal. It's match with the ID of the item in the file R.java, in hexdecimal.

- Try the Tool, hierarchyviewer, it can give you a hierarchy viewer of the current view.--------------------------------------------------------------------

If you have already installed Android 1.6 SDK and Eclipse, it's very easy to upgrade to Android SDK Tools, Revision 3. The Android SDK and AVD Manager tool is included in Android 1.6 and later SDK packages.

Android 2.0 is a major platform release deployable to Android-powered handsets starting in November 2009. The release includes new features for users and developers, as well as changes in the Android framework API.

Now, I have another approach using in Eclipse, Emulator and DDMS. May be it's more easy, at least no need to remember the text commands.

Create a new AVD in Eclipse:

- Start Eclipse, click Window on the top menu, and click Android SDK and AVD Manager.- New a AVD

- Name your new AVD, select Target, type 1000M in SD Card and select skin. Click Create.note: SD Card must be either a file path or a size such as 128K 0r 64M. type 1000M now to create a SD Card of 1G.- Select and Start the new AVD.

After the Emulator started, you can close the AVD Manager.

Create folder in SDCard

I can't find any File Manager in Android Emulator. Fortunately, Android Emulator provide a DevTools with Terminal, so you can create a folder using Linux command inside Android Emulator.

- Click the ARROW on the screen to display the available application.

- Click DevTools.

- Scroll down to start Terminal Emulator

- It's the same a terminal in Linux, you can ls to view the current files and folders in your $home.

- Now change into sdcard and create a folder, say pictures.$cd sdcard$mkdir pictures

It's the only two line of command in this approach.

Copy files from your host system into Android SDCard

- With the Emulator is running. Now go back to Eclipse, switch to DDMS Perspective

Click the arrow on the menu bar and select DDMS

or

Click Window > Open Perspective > others > to select DDMS

- Select the device in the window on the left, eg. emulator-5554. (Without select the device, you will fail in copying files into.)

- In DDMS, select File Explorer tag in the window on the right. Expend sdcard folder. Now, you can see the pictures folder in the tree. And also, you can see the Permissions of the folder.

- Select the pictures folder, and click Push a file onto the device.

- Browse to and select the files from your host, to push onto the Android Emulator.

Friday, October 23, 2009

A status bar notification adds an icon to the system's status bar (with an optional ticker-text message) and an expanded message in the "Notifications" window.

After Notification generated, a selected notification icon and Ticket will be displayed on the status bar.

User can reveal the Notifications window by pulling down the status bar (or selecting Notifications from the Home options menu), to view the Title and Content.

Notification can be generated inside Service or Activity. This exercise show the basic steps to generate a Notification in Activity.

The most important class is NotificationManager and Notification.

In the exercise:android.R.drawable.btn_star_big_on is a drawable icon in Android system resource, you can assign any drawable icon.when is when the notification should be generated, System.currentTimeMillis() = NOW.NOTIFICATION_ID is a number which is unique in your application.contentIntent is the expected intent to handle the notification. It's the own activity in this exercise.

The generated Notification can be cleared by: NotificationManager.cancel(NOTIFICATION_ID);

Modify main.xml to have two Buttons to generate and clear the Notification

Tuesday, October 20, 2009

Normally, ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. However, if you desire, you can customize the screen layout by setting your own view layout with setContentView() in onCreate(). To do this, your own view MUST contain a ListView object with the id "@android:id/list".

In some case if the list is empty, the screen will become nothing. If you want to prompt the user if the list is empty, @android:id/list and @android:id/empty can be used.

Friday, October 16, 2009

In the article Layout Animation, list_layout_controller is included in layout, main.xml. In the last article ListView and ListActivity, ListView is implemented as ListActivity, without XML file for layout. How can apply the LayoutAnimationController.

In this article, the same visual effect of Layout Animation will be applied on ListView and ListActivity.

A ListView is a View that shows items in a vertically scrolling list. The items are acquired from a ListAdapter.

In this exercise, I will show how to implement a ListView using ListActivity. The main activity (AndroidListView) call the ListActivity(AndroidListActivity) by startActivityForResult. AndroidListActivity have a ListView only, the selected item will be passed back to AndroidListView by means of Bundle.

_ Create a new Android Application named AndroidListView

- Modify main.xml to have a Button to start the ListActivity with ListView, and have a TextView to show the result from ListActivity.

Notice that we don't need to load a layout (at least, not in this case, because we're using the whole screen for our list). Instead, we just call setListAdapter() (which automatically adds a ListView to the ListActivity), and provide it with an ArrayAdapter that binds a simple_list_item_1 layout item to each entry in the COUNTRIES array (added next). The next line of code adds a text filter to the ListView, so that when the user begins typing, the list will filter the entire view to display only the items that match the entry.

Thursday, October 15, 2009

Layout Animation can be used to add visual effects on any controls derived from ViewGroup, such as ListView. ListView is a view that shows items in a vertically scrolling list. The items come from the ListAdapter associated with this view.

In this article, I will have a example to show how to implement a simple Layout Animation.

Create a Android Application named AndroidLayoutAnimation.

- Create a new folder named /anim under /res

- Create two xml file under /res/anim to handle the animationlist_layout_controller.xml

Tuesday, October 13, 2009

In the article Simulate Animation, using Runnable Thread, I described how to simulate animation using Runnable Thread. For sure, it's not a good practice. In this article I show how to implement animation using animation-list and AnimationDrawable.

The animation can be started and stopped by the two button, Start and Stop.

- Save the four graphics, used to form the animation of a rotating arrow, in the /res/drawable/ folder.

There are three EditText in the application, for user name, password (hiden by password dots) and updated status. Submit to Twitter by pressing of the Submit button. If successful, a Toast with "OK" will be shown, otherwise "ERROR" will be shown.

- Before start; base64 is needed in the application, refer to the article Use base64 in Android to download and include it in the Build Path of the project.

------------------------Actually, I can't find anywhere to download sun.misc.BASE64Encoder. Somebody advise that it can be found in /jre/lib/rt.jar. I tried to add it to my build path, but my machine hang-up in build my project. So...I give-up sun.misc.BASE64Encoder finally.------------------------