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(安卓)GridView
  2. Android屏蔽home键的代码,咋摁也不响应的方法
  3. Dalvik Optimization and Verification With dexopt
  4. Android(安卓)系统中 gps Location Service 的实现与架构,本文可
  5. 如何在android画分析图(例如 柱状图、趋势图、饼图)
  6. 加快Android单模块编译
  7. Android(安卓)Style与Theme .
  8. [置顶] Android(安卓)单击listview弹出popupwindow弹出框
  9. 加快Android单模块编译

随机推荐

  1. Android(安卓)Custom Views and XML attr
  2. drawlayout
  3. Android(安卓)SDK R14 发布
  4. Android之Activity--Loaders
  5. Android(安卓)Media Scanner Mechanism A
  6. 在android中玩转wcf
  7. android中操纵sqlite数据库
  8. Android(安卓)studio maven pom.xml
  9. Android: ADB网络调试
  10. android property system