android 动态设置TextView值,例:金额添加
一说到动态递增设置TextView值,非常多人应该立即就想到起个线程,让后在线程中睡眠指定时间,使用handler发送消息更新TextView值!
这样是实现了动态递增设置TextView值可是效率不咋滴吧,须要的话能够自己去试试,如1到100,10s内显示完,会感觉到有点卡的。
这里有个更好的方法,使用ValueAnimator进行设置,并且不须要自己去计算每次叠加后须要间隔的时间,以下是代码:
public static void autoIncrement(final TextView target, final float start,
final float end, long duration) { ValueAnimator animator = ValueAnimator.ofFloat(start, end); animator.addUpdateListener(new AnimatorUpdateListener() {
private FloatEvaluator evalutor = new FloatEvaluator();
private DecimalFormat format = new DecimalFormat("####0.0#"); @Override
public void onAnimationUpdate(ValueAnimator animation) { float fraction = animation.getAnimatedFraction();
float currentValue = evalutor.evaluate(fraction, start, end);
target.setText(format.format(currentValue));
}
});
animator.setDuration(duration);
animator.start(); }
在2s内显示1-1000的值。显示很流畅。不信能够自己试试!
android 动态设置TextView值,例:金额添加的更多相关文章
- android 动态设置TextView值,例:金额增加
一说到动态递增设置TextView值,很多人应该马上就想到起个线程,让后在线程中睡眠指定时间,使用handler发送消息更新TextView值! 这样是实现了动态递增设置TextView值但是效率不咋 ...
- Android 动态设置TextView的drawableLeft等属性
首先,我们在开发过程中,会经常使用到android:drawableLeft="@drawable/ic_launcher"这些类似的属性: 关于这些属性的意思,无非是在你的tex ...
- Android中设置TextView的颜色setTextColor
tv.setTextColor(Color.parseColor("#FFFFFF")); tv.setTextColor(Color.WHITE); tv.setTextColo ...
- 【转】Android中设置TextView的颜色setTextColor--代码中设置字体颜色
原文网址:http://www.cnblogs.com/myphoebe/archive/2012/01/06/2314728.html android中设置TextView的颜色有方法setText ...
- 【转】Android中设置TextView的颜色setTextColor
原文网址:http://www.cnblogs.com/myphoebe/archive/2012/01/06/2314728.html android中设置TextView的颜色有方法setText ...
- [转]Android中设置TextView的颜色setTextColor
[转自]http://txlong-onz.iteye.com/blog/1249609 Android中设置TextView的颜色setTextColor android中设置TextView的颜色 ...
- Android 动态设置控件获取焦点
之前写过一篇博客,简单的介绍了Android 隐藏EditText的焦点,之所以要隐藏EditText的焦点,是因为当应用在第一次进入某个Activity时,由于该页面中的EditText获取了焦点, ...
- Android如何设置TextView的行间距、行高。
Android系统中TextView默认行间距比较窄,不美观. 我们可以设置每行的行间距,可以通过属性android:lineSpacingExtra或android:lineSpa ...
- Ext.form.Label组件动态设置html值
解决方法: (1)用的是 Ext.getCmp(id).setText('XXXX')可以动态设置label 显示的文本值,但是文本中有个别数字需要改变颜色显示,需要加样式,这种方法会把加样式的标签( ...
随机推荐
- 51nod-1322: 关于树的函数
[传送门:51nod-1322] 简要题意: 给出n个点的两棵无根树,编号都是从0到n-1 现在每棵树任意选出一条边割断,设第一棵树选出的边为e1,第二棵树选出的边为e2 很显然割断后两棵树各分成了四 ...
- Data Member Order
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/data-member-order In some appl ...
- CSS提高渲染速度的写法
写CSS的习惯,决定页面渲染速度的快慢,这一点在脑残的IE里更加明显.养成良好的习惯,乃至形成规范,会让你的页面更快速的加载,用户体验度更高,下面是零度逍遥总结的一些提高CSS渲染速度的写法,供大家参 ...
- YYDispatchQueuePool阅读笔记
阅读了开源大神的YYDispatchQueuePool,在此记下一些从中学到的东西. 首先YYDispatchQueuePool.m文件中有如下类型对应: static inline dispatch ...
- Java中将String转json对象
import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple. ...
- LINUX 上源代码安装与配置samba服务,支持从windows上读写LINUX文件。
###动机###在windows编写代码文件比较方便,因为有source insight.但是需要在LINUX上编译.一种办法就是使用samba文件共享. [1] 下载samba代码.按照config ...
- 紫书 例题 10-10 UVa 10491(概率计算)
公式很好推,表示被高中生物遗传概率计算虐过的人 这个公式简直不需要动脑 #include<cstdio> using namespace std; int main() { double ...
- PKU 3311 Hie with the Pie 状态DP
Floyd + 状态DP Watashi的板子 #include <cstdio> #include <cstring> #include <iostream> # ...
- 【Facebook的UI开发框架React入门之九】button简单介绍(iOS平台)-goodmao
--------------------------------------------------------------------------------------------------- ...
- Shell脚本中替换字符串等操作
在做shell批处理程序时候,常常会涉及到字符串相关操作. 有非常多命令语句.如:awk,sed都能够做字符串各种操作. 事实上shell内置一系列操作符号.能够达到类似效果,大家知道,使用内部操作符 ...