カスタム ビューを作成しましたが、そこからカスタム定義の色にアクセスできないようです。私のアプリ全体は、次の 3 つのファイルで構成されています
res/values フォルダーにある colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#000000</color>
</resources>
TestView.java:
public class TestView extends View {
    Paint background;
    int viewWidth;
    int viewHeight;
    public TestView(Context context){
        super(context);
        background = new Paint();
        background.setColor(getResources().getColor(R.color.black));
        //find view dimensions
        viewWidth = getWidth();
        viewHeight = getHeight();
    }
    @Override 
    protected void onDraw(Canvas canvas){
        super.onDraw(canvas);
        canvas.drawRect(0,0,viewWidth,viewHeight, background);      
    }
}
および MainActivity.java:
public class MainActivity extends Activity {
    private static final String TAG = "MainActivity";
    TestView testView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        testView = new TestView(this);
        setContentView(testView);
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
私が得るのは、黒いはずの空白の白い画面だけです! 私はこれを約2日間続けて引き起こしている可能性があるものを理解しようとしてきましたが、言うまでもなく、うまくいかなかった多くのことを試しました. 誰かがこれで私を助けることができれば、私は非常に感謝しています.
ありがとう!