# Por favor me digam onde esta o erro, que não consigo resolver

**URL:** <https://discuss.kotlinlang.org/t/por-favor-me-digam-onde-esta-o-erro-que-nao-consigo-resolver/20788>\
**Category:** Android\
**Created:** [February 7, 2021, 8:16pm UTC](https://discuss.kotlinlang.org/t/por-favor-me-digam-onde-esta-o-erro-que-nao-consigo-resolver/20788 "2021-02-07T20:16:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gommello](https://avatars.discourse-cdn.com/v4/letter/g/f6c823/32.png) [@gommello](https://discuss.kotlinlang.org/u/gommello)\
**Post date:** [February 7, 2021, 8:16pm UTC](https://discuss.kotlinlang.org/t/por-favor-me-digam-onde-esta-o-erro-que-nao-consigo-resolver/20788/1 "2021-02-07T20:16:04Z")

</div>

```
              **APP EM ANDROID STUDIO KOTLIN**![foto listview|375x500](upload://liJfNSsTtTUuUWl8qFfpZkfPnKq.jpeg) 

```

Pessoal sou novato do novato no android studio kotlin tambem no java…  
Estou desenvolvendo uma aplicativo sobre compras em supermercado…  
Do inicio até o comentado serrilhado não tem nenhum problema.  
Aparece a ListView com todas os produtos…  
O meu problema esta que quando dou click em qualquer linha da ListView não estou conseguindo marcar checktextview…  
Agradeço quem possa me ajudar…  
Obrigado

import android.os.Bundle  
import android.view.View  
import android.widget.CheckedTextView  
import android.widget.ListView  
import android.widget.Toast  
import androidx.appcompat.app.AppCompatActivity  
import androidx.cursoradapter.widget.SimpleCursorAdapter

class ListaActivity : AppCompatActivity() {  
//var inflter: LayoutInflater? = null  
var value: String? = null  
private val names: Long? = null  
private var dbManager: DBManager? = null  
private var listView: ListView? = null  
private var adapter: SimpleCursorAdapter? = null  
private val from = arrayOf(DatabaseHelper.\_ID, DatabaseHelper.SUBJECT, DatabaseHelper.DESC)  
private val to = intArrayOf(R.id.id, R.id.title)  
override fun onCreate(savedInstanceState: Bundle?) {  
super.onCreate(savedInstanceState)  
setContentView(R.layout.activity\_lista)

```
    dbManager = DBManager(this)
    dbManager!!.open()
    val cursor = dbManager!!.fetch()
    listView = findViewById<View>(R.id.list_view) as ListView
    listView!!.emptyView = findViewById(R.id.empty)
    adapter = SimpleCursorAdapter(this, R.layout.activity_view_record, cursor, from, to, 0)
    adapter!!.notifyDataSetChanged()
    listView!!.adapter = adapter

    listView!!.setOnItemClickListener { parent, view, position, id ->
        Toast.makeText(this, "Clicked item : $position", Toast.LENGTH_SHORT).show()

```

//--------------------------Toast para cima funciona perfeitamente o problema e abaixo---------------------------------------------------------------//  
}  
val checkedTextView = findViewById(R.id.checkedTextView)  
if (checkedTextView != null) {  
checkedTextView.isChecked = false  
checkedTextView.setCheckMarkDrawable(android.R.drawable.checkbox\_off\_background)

```
        checkedTextView.setOnClickListener {
            checkedTextView.isChecked = !checkedTextView.isChecked
            checkedTextView.setCheckMarkDrawable(if (checkedTextView.isChecked) android.R.drawable.checkbox_on_background else android.R.drawable.checkbox_off_background)

            val msg = getString(R.string.pre_msg) + " " + getString(if (checkedTextView.isChecked) R.string.checked else R.string.unchecked)
            Toast.makeText(this@ListaActivity, msg, Toast.LENGTH_SHORT).show()
        }
    }
}
}

```
