Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unresolved reference: inflate

override fun getView(p0: Int, p1: View?, p2: ViewGroup?): View {
            var myView=LayoutInflater.inflate(R.layout.row_custom_listitem, null)
            var myNote=listNotes[p0]
            myView.tvTitle.text=myNote.noteName
            myView.tvDes.text=myNote.noteDes

The output is:

Unresolved reference: inflate

I selected import under the red mark at inflate, but there is no change. The packages have been imported but inflate is still underlined in red. Kindly help me to solve this issue.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

override fun getView(p0: Int, p1: View?, p2: ViewGroup?): View {
            var myView= getLayoutInflater().inflate(R.layout.row_custom_listitem, null)
            var myNote=listNotes[p0]
            myView.tvTitle.text=myNote.noteName
            myView.tvDes.text=myNote.noteDes
        }

I modified my code as above, but I am not sure if this is right or will do the same job.

>Solution :

Try this .

You have not return the view and must initialize the TextView

  @Override
    fun getView(position: Int, convertView: View?, parent: ViewGroup?): View? {
        val myView: View = layoutInflater.inflate(R.layout.row_custom_listitem, null)
        val tvTitle= myView.findViewById<View>(R.id.tvTitle) as TextView
        val tvDes= myView.findViewById<View>(R.id.tvDes) as TextView
        tvTitle.text = "some value"
        tvDes.text = "another value"
        return myView
    }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading