首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

卡通-闪烁的文字-用的是线程

2012-09-27 
动画---闪烁的文字--用的是线程public class ActivityMain extends Activity {public void onCreate(Bundl

动画---闪烁的文字--用的是线程

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(执行间隔)}}

热点排行