Department of famous Door Android (8)

Source: Internet
Author: User

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;
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.