当前位置:网站首页>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>
边栏推荐
- 国内首创!Todesk将RTC技术融入远程桌面,画质更清晰操作更流畅
- Matplotlib绘制三维图形
- Flash build API Service - generate API documents
- LeetCode 403. Frog crossing the river daily
- LeetCode 497(C#)
- Share the latest high-frequency Android interview questions, and take you to explore the Android event distribution mechanism
- 麒麟信安加入宁夏商用密码协会
- 【网络攻防原理与技术】第6章:特洛伊木马
- 【网络攻防原理与技术】第3章:网络侦察技术
- Skimage learning (2) -- RGB to grayscale, RGB to HSV, histogram matching
猜你喜欢
随机推荐
防火墙系统崩溃、文件丢失的修复方法,材料成本0元
[source code interpretation] | source code interpretation of livelistenerbus
The computer cannot add a domain, and the Ping domain name is displayed as the public IP. What is the problem? How to solve it?
【信息安全法律法规】复习篇
Sator推出Web3遊戲“Satorspace” ,並上線Huobi
What is cloud computing?
本周小贴士#140:常量:安全习语
【可信计算】第十一次课:TPM密码资源管理(三) NV索引与PCR
From Devops to mlops: how do it tools evolve to AI tools?
到底有多二(Lua)
rpcms获取指定分类下的文章的方法
本周小贴士#134:make_unique与私有构造函数
《世界粮食安全和营养状况》报告发布:2021年全球饥饿人口增至8.28亿
【信息安全法律法規】複習篇
Nerf: the ultimate replacement for deepfake?
【饭谈】那些看似为公司着想,实际却很自私的故事 (一:造轮子)
NeRF:DeepFake的最终替代者?
99% 用户在 Power BI 云端报表常犯错误
PLC: automatically correct the data set noise, wash the data set | ICLR 2021 spotlight
第3章业务功能开发(用户访问项目)