How to access values from strings.xml

前端 未结 4 854
再見小時候
再見小時候 2020-12-09 15:18

How can I access values from strings.xml in kotlin android?

class MainActivity : AppCompatActivity(), View.OnClickListener {
    override fun onClick(p0: Vie         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 15:52

    If it helps this is how I did it - you need the application context and also to import the R Class

    applicationContext.getString(R.string.text_string)
    import com.example.yourpackagename.R
    

提交回复
热议问题