当前位置:网站首页>textSwitch文本切换器的功能和用法
textSwitch文本切换器的功能和用法
2022-07-07 15:40:00 【XLMN】
textSwitch文本切换器的功能和用法
testswitch继承了viewswitch,因此据有和viewswitcher相同的特征,可以在切换view组件时使用动画效果,
testswitcher和imageview相识需要设置一个viewfactory,不同的在于,testswitcher需要viewfactory的makeview返回一个textview组件
public class MainActivity extends Activity {
TextSwitcher ts;
String[] str=new String[]{
“mia”,“love mia”,“miss mia”,“010802”
};
int curstr;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.textswitcher);
ts = (TextSwitcher) findViewById(R.id.textswitcher);
ts.setFactory(new ViewFactory() {
@Override
public View makeView() {
// TODO Auto-generated method stub
TextView tv=new TextView(MainActivity.this);
tv.setTextSize(40);
tv.setTextColor(Color.MAGENTA);
return tv;
}
});
next(null);
}
//定义处理函数,控制显示下一个字符串
public void next(View source) {
ts.setText(str[curstr++%str.length]);
}
}
<?xml version="1.0" encoding="utf-8"?><!-- 定义一个testswitcher,并指定文本切换时的动画效果 -->
<TextSwitcher
android:id="@+id/textswitcher"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inAnimation="@android:anim/slide_in_left"
android:onClick="next"
android:outAnimation="@android:anim/slide_out_right" >
</TextSwitcher>

边栏推荐
- 99% 用户在 Power BI 云端报表常犯错误
- 使用Stace排除故障的5种简单方法
- 跟奥巴马一起画方块(Lua)
- 字符串 - string(Lua)
- 智慧物流平台:让海外仓更聪明
- 百度地图自定义样式向右拖拽导致全球地图经度0度无法正常显示
- 【网络攻防原理与技术】第5章:拒绝服务攻击
- The mail server is listed in the blacklist. How to unblock it quickly?
- Skimage learning (2) -- RGB to grayscale, RGB to HSV, histogram matching
- Sator a lancé le jeu web 3 "satorspace" et a lancé huobi
猜你喜欢

Sator a lancé le jeu web 3 "satorspace" et a lancé huobi

Lex & yacc of Pisa proxy SQL parsing

Skimage learning (3) -- adapt the gray filter to RGB images, separate colors by immunohistochemical staining, and filter the maximum value of the region

第3章业务功能开发(用户访问项目)

【TPM2.0原理及应用指南】 9、10、11章

mysql官网下载:Linux的mysql8.x版本(图文详解)

【信息安全法律法规】复习篇

命令模式 - Unity

管理VDI的几个最佳实践

Skimage learning (1)
随机推荐
【黄啊码】为什么我建议您选择go,而不选择php?
服务器彻底坏了,无法修复,如何利用备份无损恢复成虚拟机?
赋能智慧电力建设 | 麒麟信安高可用集群管理系统,保障用户关键业务连续性
【TPM2.0原理及应用指南】 5、7、8章
Sator推出Web3游戏“Satorspace” ,并上线Huobi
Problems encountered in Jenkins' release of H5 developed by uniapp
Smart logistics platform: make overseas warehouses smarter
Biped robot controlled by Arduino
Jenkins发布uniapp开发的H5遇到的问题
如何在软件研发阶段落地安全实践
第3章业务功能开发(用户登录)
第二十四届中国科协湖南组委会调研课题组一行莅临麒麟信安调研考察
【信息安全法律法規】複習篇
本周小贴士#136:无序容器
【可信计算】第十二次课:TPM授权与会话
User defined view essential knowledge, Android R & D post must ask 30+ advanced interview questions
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
mysql官网下载:Linux的mysql8.x版本(图文详解)
浅谈 Apache Doris FE 处理查询 SQL 源码解析
VSCode关于C语言的3个配置文件