当前位置:网站首页>Function and usage of textswitch text switcher
Function and usage of textswitch text switcher
2022-07-07 17:36:00 【XLMN】
textSwitch Function and usage of text switcher
testswitch Inherited viewswitch, Therefore, possession and viewswitcher Same features , You can switch view Use animations for components ,
testswitcher and imageview Acquaintance requires a viewfactory, The difference is ,testswitcher need viewfactory Of makeview Return to one textview Components
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);
}
// Define processing functions , Controls the display of the next string
public void next(View source) {
ts.setText(str[curstr++%str.length]);
}
}
<?xml version="1.0" encoding="utf-8"?><!-- Define a testswitcher, And specify the animation effect when text switching -->
<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>

边栏推荐
猜你喜欢
随机推荐
数值 - number(Lua)
First in China! Todesk integrates RTC technology into remote desktop, with clearer image quality and smoother operation
[Huang ah code] Why do I suggest you choose go instead of PHP?
Matplotlib绘制三维图形
datepicket和timepicket,日期、时间选择器的功能和用法
第3章业务功能开发(用户登录)
【网络攻防原理与技术】第6章:特洛伊木马
SIGGRAPH 2022最佳技术论文奖重磅出炉!北大陈宝权团队获荣誉提名
LeetCode 890(C#)
麒麟信安加入宁夏商用密码协会
99% of users often make mistakes in power Bi cloud reports
Flask搭建api服务-SQL配置文件
阿富汗临时政府安全部队对极端组织“伊斯兰国”一处藏匿点展开军事行动
[fan Tan] those stories that seem to be thinking of the company but are actually very selfish (I: building wheels)
Several best practices for managing VDI
【网络攻防原理与技术】第5章:拒绝服务攻击
Solid function learning
【TPM2.0原理及应用指南】 16、17、18章
Repair method of firewall system crash and file loss, material cost 0 yuan
第2章搭建CRM项目开发环境(数据库设计)









