Department of famous Door Android (8)-Control (View) textswitcher,gallery,imageswitcher,gridview,listview,expandablelist
Introduced
Use various controls in Android (View)
Textswitcher-Text converter control (adds some animation effects when changing text)
Gallery-Thumbnail Browser Control
Imageswitcher-Picture Converter control (add some animation effects when changing a picture)
GridView-Grid Control
ListView-List control
Expandablelist-list controls that support expand/shrink capabilities
1, Textswitcher's Demo
Textswitcher.xml
<?xml version= "1.0" encoding= "Utf-8"
<linearlayout xmlns:android= "http://" Schemas.android.com/apk/res/android "
android:orientation=" vertical " android: Layout_width= "Fill_parent"
android:layout_height= "fill_parent"
<button android:id= "@+id/btnchange" android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" android:text= "Change Text" />
<!--
textswitcher - the Text converter control (adds some animation effects when text is changed)
-->
<textswitcher android:id= "@+id/textswitcher"
Android:layout_width= "Fill_parent" android:layout_height= "wrap_content" &NBSP;/>
</ Linearlayout>
_textswitcher.java
Package Com.webabcd.view;
Import Java.util.Random;
Import android.app.Activity;
Import Android.os.Bundle;
Import Android.view.View;
Import android.view.animation.Animation;
Import Android.view.animation.AnimationUtils;
Import Android.widget.Button;
Import Android.widget.TextSwitcher;
Import Android.widget.TextView;
Import Android.widget.ViewSwitcher;
public class _textswitcher extends activity implements Viewswitcher.viewfactory {
@Override
protected void OnCreate (Bundle savedinstancestate) {
TODO auto-generated Method Stub
Super.oncreate (savedinstancestate);
This.setcontentview (R.layout.textswithcer);
Settitle ("Textswithcer");
Final Textswitcher switcher= (textswitcher) Findviewbyid (R.id.textswitcher);
Specify the viewswitcher.viewfactory of the converter
Switcher.setfactory (this);
Set the animation effect of fade in and fade
Animation In=animationutils.loadanimation (this, Android. R.ANIM.FADE_IN);
Animation Out=animationutils.loadanimation (this, Android. R.anim.fade_out);
Switcher.setinanimation (in);
Switcher.setoutanimation (out);
Click the button once to change the text once
Button btnchange= (button) This.findviewbyid (R.id.btnchange);
Btnchange.setonclicklistener (New View.onclicklistener () {
@Override
public void OnClick (View v) {
Switcher.settext (string.valueof (New Random (). Nextint ()));
}
});
}
Rewrite the viewswitcher.viewfactory Makeview () to return to a View
@Override
Public View Makeview () {
TextView textview=new TextView (this);
Textview.settextsize (36);
return textView;
}
}