1.布局文件:activity_main.xml

    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    >
            android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center"
        android:id="@+id/myText"/>


2.Activity视图文件:

package com.wh.lcdtest;


import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.TextView;
/**
 * @author wh
 * @Date 2012-08-07
 * @version V0.0
 */
public class MainActivity extends Activity implements OnClickListener{


TextView myTextView;
int flag;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        myTextView = (TextView) findViewById(R.id.myText);
        myTextView.setText("欢迎使用屏幕测试程序!!请点击屏幕开始测试!!");
        myTextView.setTextColor(Color.WHITE);
        myTextView.setOnClickListener(this);
        flag=1;
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    public void onClick(View view){
    
    String mStr="LCD TEST!!";
    System.out.println(mStr);
    myTextView.setText("");


    flag = flag%5;
    
    switch(flag)
    {
  case 0:
  myTextView.setBackgroundColor(Color.WHITE); break;
 
  case 1:
 myTextView.setBackgroundColor(Color.RED); break;
 
  case 2:
  myTextView.setBackgroundColor(Color.GREEN); break;
  
  case 3:
  myTextView.setBackgroundColor(Color.BLUE); break;
 
  case 4:
  myTextView.setBackgroundColor(Color.BLACK); break;
    
    }
   flag++;


    }
}

3.运行效果:



4.源代码链接:http://download.csdn.net/detail/feihuiwu123/4483628

更多相关文章

  1. Android(安卓)textView文字添加图片 imageSpan使用
  2. android中重写onTouchEvent分别实现点击和滑动事件
  3. 初学Android,数据存储之SD卡文件浏览器(四十四)
  4. android读取raw下面的文件
  5. Linux 统计代码行数
  6. 【android 文件的基本操作】
  7. TextView 在xml文件中的解释 android
  8. Android的Eclipse升级笔记
  9. Android(安卓)自定义对话框(控制大小、位置)

随机推荐

  1. W EB:一种基于网络嵌入的互联网借贷欺诈预
  2. 农业大数据建设的需求、模式与单品种全产
  3. Hadoop下水环境模拟集群运算模式
  4. 《大数据》编辑部恭贺新春!!!
  5. 基于APMSSGA-LSTM的容器云资源预测
  6. 基于数据空间的电子病历数据融合与应用平
  7. 处理类似Globeimposter-Alpha865qqz勒索
  8. 数据管护技术及应用
  9. 坚果云与亿方云功能差异
  10. 工业时序大数据质量管理