SORU
16 EKİM 2011, Pazar


, () Kendi tanımlı Düzen onDraw adı alma yöntemi

O, s gibi bir sınıf tanımlanmış

public class TestMyFrameLayout extends FrameLayout{

    Paint mPaint;
    public TestMyFrameLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public TestMyFrameLayout(Context context) {
        super(context);
        mPaint = new Paint();
        mPaint.setColor(Color.GREEN);
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawCircle(50f, 50f, 30, mPaint);
    }   
}

ve şöyle denir:

TestMyFrameLayout myFrameLayout = new TestMyFrameLayout(this);
LayoutParams myFrameLayoutParams = new LayoutParams(300,300);
myFrameLayout.setLayoutParams(myFrameLayoutParams);
setContentView(myFrameLayout);

Ama aslında TestMyFrameLayout.onDraw(Kanvas tuval) adlı fonksiyonu yok, neden?

CEVAP
16 EKİM 2011, Pazar


Çözüldü. Ekle this.setWillNotDraw(false); kurucu

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Major FX

    Major FX

    6 HAZİRAN 2012
  • PCDIY

    PCDIY

    16 AĞUSTOS 2013
  • VideoGamePervert

    VideoGamePer

    30 AĞUSTOS 2008