14.01.2013 Views

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

});<br />

// TODO Do something when the animation repeats.<br />

public void onAnimationStart(Animation _animation) {<br />

// TODO Do something when the animation starts.<br />

}<br />

Animated Sliding User Interface Example<br />

Chapter 11: Advanced Android <strong>Development</strong><br />

In this example, you’ll create a new Activity that uses an Animation to smoothly change the content of<br />

the User Interface based on the direction pressed on the D-pad.<br />

1. Start by creating a new ContentSlider project featuring a ContentSlider Activity.<br />

package com.paad.contentslider;<br />

import android.app.Activity;<br />

import android.view.KeyEvent;<br />

import android.os.Bundle;<br />

import android.view.animation.Animation;<br />

import android.view.animation.Animation.AnimationListener;<br />

import android.view.animation.AnimationUtils;<br />

import android.widget.TextView;<br />

public class ContentSlider extends Activity {<br />

@Override<br />

public void onCreate(Bundle icicle) {<br />

super.onCreate(icicle);<br />

setContentView(R.layout.main);<br />

}<br />

}<br />

2. Next, modify the main.xml layout resource. It should contain a single TextView with the text<br />

bold, centered, and relatively large.<br />

<br />

<br />

<br />

<br />

365

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!