package com.yanjun;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity {
/** Called when the activity is first created. */
Button button;
TextView textView;
int[] mcolors;
int colorNumber = 0;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textView = (TextView) findViewById(R.id.textView1);
button = (Button) findViewById(R.id.button1);
mcolors = new int[] { Color.BLACK, Color.BLUE, Color.CYAN,
Color.DKGRAY, Color.LTGRAY, Color.GRAY, Color.GREEN };
button.setOnClickListener( new OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
if (colorNumber < mcolors.length) {
textView.setTextColor(mcolors[colorNumber]);
colorNumber++;
} else {
colorNumber = 0;
}
}
});
}
}

本文出自 “Android的一点一滴” 博客,请务必保留此出处http://haiyuanxi.blog.51cto.com/4230602/1010149

更多相关文章

  1. Android 系统中 gps Location Service 的实现与架构,本文可以帮助
  2. Android 点击按钮,文本文字改变
  3. 分析脚本文件AndroidInitProcess分析心得(1)
  4. Android通知栏消息(基本文字通知)
  5. Android判断网络状态是否断开+Android完全关闭应用程序+ 本文讲
  6. Android下载文本文件和mp3文件
  7. Android-TextView多行本文滚动轻松实现
  8. 解析PHP的基本文本输出
  9. Linux hostname主机名配置文件/etc/hosts详解 详细出处参考:http:

随机推荐

  1. AI一周热闻:IBM收购Red Hat;马斯克辞去特斯
  2. 通过一个简单的案例看懂量子计算机
  3. 谷歌官宣:全面超越人类的最强NLP预训练模
  4. 坚果云和亿方云哪个好用?
  5. 坚果云和亿方云哪个更适合学校?
  6. RocketMQ 初探
  7. 看透 Spring MVC 源代码分析与实践 ——
  8. SpringBoot RabbitMQ 整合进阶版
  9. 看透 Spring MVC 源代码分析与实践 ——
  10. SpringBoot ActiveMQ 整合使用