android字体闪烁动画(线程)
6,129 views
0
android字体闪烁动画,使用线程和Timer实现
public class ActivityMain extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); spark(); } private int clo = 0; public void spark() { final TextView touchScreen = (TextView) findViewById(R.id.TextView01);// 获取页面textview对象 Timer timer = new Timer(); TimerTask taskcc = new TimerTask(){ public void run() { runOnUiThread(new Runnable() { public void run() { if (clo == 0) { clo = 1; touchScreen.setTextColor(Color.TRANSPARENT); // 透明 } else { if (clo == 1) { clo = 2; touchScreen.setTextColor(Color.RED); } else { clo = 0; touchScreen.setTextColor(Color.GREEN); } } } }); } }; timer.schedule(taskcc, 1, 300); // 参数分别是delay(多长时间后执行),duration(执行间隔) } }
版权所有: 本文系米扑博客原创、转载、摘录,或修订后发表,最后更新于 2011-08-23 20:02:12
侵权处理: 本个人博客,不盈利,若侵犯了您的作品权,请联系博主删除,莫恶意,索钱财,感谢!
转载注明: android字体闪烁动画(线程) (米扑博客)