当前位置:网站首页>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>
边栏推荐
- MRS离线数据分析:通过Flink作业处理OBS数据
- Establishment of solid development environment
- Enum + Validation 的个人最佳实践 demo 分享
- Skimage learning (3) -- adapt the gray filter to RGB images, separate colors by immunohistochemical staining, and filter the maximum value of the region
- 如何在软件研发阶段落地安全实践
- [image sensor] correlated double sampling CDs
- L1-023 输出GPLT(Lua)
- NeRF:DeepFake的最终替代者?
- Nerf: the ultimate replacement for deepfake?
- 本周小贴士#141:注意隐式转换到bool
猜你喜欢
麒麟信安携异构融合云金融信创解决方案亮相第十五届湖南地区金融科技交流会
[video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial
第3章业务功能开发(用户登录)
Devops' operational and commercial benefits Guide
【可信计算】第十三次课:TPM扩展授权与密钥管理
DevOps 的运营和商业利益指南
第3章业务功能开发(实现记住账号密码)
Linux 安装mysql8.X超详细图文教程
【重新理解通信模型】Reactor 模式在 Redis 和 Kafka 中的应用
[Seaborn] combination chart: facetgrid, jointgrid, pairgrid
随机推荐
Reflections on "product managers must read: five classic innovative thinking models"
Seaborn data visualization
Flash build API service
The mail server is listed in the blacklist. How to unblock it quickly?
第3章业务功能开发(用户登录)
科普达人丨一文弄懂什么是云计算?
On Apache Doris Fe processing query SQL source code analysis
mysql使用笔记一
Skimage learning (2) -- RGB to grayscale, RGB to HSV, histogram matching
【TPM2.0原理及应用指南】 9、10、11章
How to add aplayer music player in blog
鲲鹏开发者峰会2022 | 麒麟信安携手鲲鹏共筑计算产业新生态
Nerf: the ultimate replacement for deepfake?
[video / audio data processing] Shanghai daoning brings you elecard download, trial and tutorial
智慧物流平台:让海外仓更聪明
本周小贴士#135:测试约定而不是实现
Matplotlib绘制三维图形
【可信计算】第十三次课:TPM扩展授权与密钥管理
【饭谈】Web3.0到来后,测试人员该何去何从?(十条预言和建议)
DNS series (I): why does the updated DNS record not take effect?