部分代码如下:
import android.os.Bundle;
import android.widget.*;
import android.app.Activity;
import android.view.Menu;
import android.view.KeyEvent;
import android.view.View;
import android.graphics.drawable.*;
import android.graphics.drawable.Drawable;
import android.content.res.Resources;
import android.graphics.Color;
public class MainActivity extends Activity {
TextView textView;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button button1 =(Button)findViewById(R.id.Button1);
final Button button2 =(Button)findViewById(R.id.Button2);
final Button button3 =(Button)findViewById(R.id.Button3);
textView =(TextView)findViewById(R.id.myTextView);
Resources resource=this.getBaseContext().getResources();
final Drawable red_Drawable=resource.getDrawable(R.drawable.RED);
final Drawable blue_Drawable=resource.getDrawable(R.drawable.BLUE);
final Drawable yellow_Drawable=resource.getDrawable(R.drawable.YELLOW);