android 屏幕测试程序 测试R G B三色 和 全黑, 全白5种状态

来源:互联网 发布:安安电子狗软件 编辑:程序博客网 时间:2024/05/11 10:30

1.布局文件:activity_main.xml

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


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