Ameer Alkateeb
Ameer Alkateeb

Reputation: 31

kotlin work with Resources (array and function parameter)

I need to define array of RAW Resources by using kotlin for example

    var x = ArrayList<Resources > 
    x.add(R.raw.cat)

and the other question is to pass resource to function

fun myFun(res:Resources ){
   mp=MediaPlayer()
   mp.start(res)
 }

I will be very thanksfull for help

Upvotes: 1

Views: 902

Answers (1)

CrazyApple
CrazyApple

Reputation: 482

You maybe need a Int instead of Resources to reference a resource id:

var x = ArrayList<Int> 
x.add(R.raw.cat)

fun myFun(resId: Int) {
    mp=MediaPlayer()
    mp.start(resId)
}

Upvotes: 1

Related Questions