Code example for Context

Methods: getResources

0
        setContentView(container);
    } 
     
    @SuppressWarnings({"UnusedDeclaration"}) 
    static int dipToPx(Context c, int dip) {
        return (int) (c.getResources().getDisplayMetrics().density * dip + 0.5f);
    } 
 
    static class ColorView extends View {
        ColorView(Context c) {
            super(c);
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawRGB(0, 255, 0);
        } 
    } 
 
    static class DirtyBitmapView extends FrameLayout {