# Edittext and filter a recyclerview

**URL:** <https://discuss.kotlinlang.org/t/edittext-and-filter-a-recyclerview/9236>\
**Category:** Uncategorized\
**Created:** [August 28, 2018, 7:35am UTC](https://discuss.kotlinlang.org/t/edittext-and-filter-a-recyclerview/9236 "2018-08-28T07:35:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![traxes44](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@traxes44](https://discuss.kotlinlang.org/u/traxes44)\
**Post date:** [August 28, 2018, 7:35am UTC](https://discuss.kotlinlang.org/t/edittext-and-filter-a-recyclerview/9236/1 "2018-08-28T07:35:18Z")

</div>

Hello

I have a problem.  
My recyclerview load a MultableList.

I have an EditText in this actvity.  
When i edit this edittext i create a new mutablelist (filter) to asign in the adapter.  
But i have a problem, the word “this” have not the correct type.

Why is my problem ?  
I must create a new adapter ?

> _**rechercheniveau.addTextChangedListener(object : TextWatcher {**_  
> _**override fun afterTextChanged(p0: Editable?) {**_
> 
> _ **nivs?.forEach { NIV -\>** _  
> _**//println(NIV.code)**_  
> _**//println(p0.toString())**_  
> _**if (NIV.code.contains(p0.toString(),false)){**_  
> _**println(“EDIT”)**_  
> _**nivsfilter.add(NIVEAUX(NIV.code,NIV.desi,0,NIV.cptniv))**_
> 
> _ **}** _  
> _ **}** _  
> _**adapter = NiveauxAdapter(nivsfilter,this)**_
> 
> _**val recyclerView = findViewById(R.id.niv\_recycler\_view) as RecyclerView**_  
> _**recyclerView.layoutManager = LinearLayoutManager(this)**_  
> _ **recyclerView.adapter = adapter** _
> 
> _ **}** _
> 
> _**override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {**_  
> _ **}** _
> 
> _**override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {**_  
> _ **}** _  
> _**})**_
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![jakepurple13](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/jakepurple13/32/5440_2.png) [@jakepurple13](https://discuss.kotlinlang.org/u/jakepurple13)\
**Post date:** [August 28, 2018, 2:15pm UTC](https://discuss.kotlinlang.org/t/edittext-and-filter-a-recyclerview/9236/2 "2018-08-28T14:15:17Z")

</div>

The ‘this’ is looking at the TextWatcher not the Activity. You need to do ‘this@[activity]’

---

<div class="post-metadata">

**Author:** ![traxes44](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@traxes44](https://discuss.kotlinlang.org/u/traxes44)\
**Post date:** [August 29, 2018, 2:01pm UTC](https://discuss.kotlinlang.org/t/edittext-and-filter-a-recyclerview/9236/3 "2018-08-29T14:01:43Z")

</div>

Tank’s so much.
