The following code shows how to Add animation to ListActivity.
res/anim/list_animation.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <alpha android:duration="50" android:fromAlpha="0" android:toAlpha="1" /> <translate android:duration="100" android:fromYDelta="-100%" android:toYDelta="0%" /> </set>
Java code
//from w w w. j av a2s . c o m import android.app.ListActivity; import android.os.Bundle; import android.view.animation.AnimationUtils; import android.view.animation.LayoutAnimationController; import android.widget.ArrayAdapter; public class MainActivity extends ListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getListView().setLayoutAnimation( new LayoutAnimationController(AnimationUtils.loadAnimation( this, R.anim.list_animation), 0.5f)); setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Countries.COUNTRIES)); } public static final String[] COUNTRIES = new String[] { "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Vietnam", "Wallis and Futuna", "Western Sahara", "Yemen", "Yugoslavia", "Zambia", "Zimbabwe" }; }