Test_TextSwitcher 使用方法
来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-01 16:23 点击:次
package com.txt;
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 Test_TextSwitcher extends Activity implements ViewSwitcher.ViewFactory{
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 Test_TextSwitcher extends Activity implements ViewSwitcher.ViewFactory{
TextSwitcher ts;
TextView tv2;
private int poinst=0;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text_switcher);
Button btn = (Button) this.findViewById(R.id.Button01);
ts = (TextSwitcher) this.findViewById(R.id.TextSwitcher01);
tv2 = (TextView) this.findViewById(R.id.TextView01);
tv2.setTextSize(36);
ts.setFactory(this);
// 指定转换器的 ViewSwitcher.ViewFactory
// 设置淡入和淡出的动画效果
Animation in = AnimationUtils.loadAnimation(this,R.anim.zoomin);
Animation out = AnimationUtils.loadAnimation(this,R.anim.zoomout);
ts.setInAnimation(in);
ts.setOutAnimation(out);
TextView tv2;
private int poinst=0;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text_switcher);
Button btn = (Button) this.findViewById(R.id.Button01);
ts = (TextSwitcher) this.findViewById(R.id.TextSwitcher01);
tv2 = (TextView) this.findViewById(R.id.TextView01);
tv2.setTextSize(36);
ts.setFactory(this);
// 指定转换器的 ViewSwitcher.ViewFactory
// 设置淡入和淡出的动画效果
Animation in = AnimationUtils.loadAnimation(this,R.anim.zoomin);
Animation out = AnimationUtils.loadAnimation(this,R.anim.zoomout);
ts.setInAnimation(in);
ts.setOutAnimation(out);
btn.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
String str = String.valueOf(new Random().nextInt());
if(poinst==0){
ts.setText("sdgfdjksvbhjdfkvbhdfjklbkldfbdfjkbddddfgfbf");
poinst++;
}
else{
ts.setText("111111111111111111111111111111111111111111111111");
poinst=0;
}
&nbs
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>