Try to search your question here, if you can't find : Ask Any Question Now ?

property getter or setter expected

HomeCategory: stackoverflowproperty getter or setter expected
pragati asked 1 week ago

I want to use a bitmap var in a class. It makes ‘property getter or setter expected’ error. What is the problem?
The error shows around ‘bmp? : Bitmap = null’.
How can I solve the problem?

And I don’t understand why I must use getter or setter for private properties in a class.

class MyView(context: Context?) : View(context) {
    private var bmp? : Bitmap = null

    init {
        bmp = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
    }

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        canvas?.drawColor(Color.BLUE)
        canvas?.drawBitmap(bmp,10f,10f, null)
    }
}
1 Answers
Best Answer
Jyoti answered 1 week ago
Your Answer

11 + 9 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com