# How to refresh or update recycle view every time with new message

**URL:** <https://discuss.kotlinlang.org/t/how-to-refresh-or-update-recycle-view-every-time-with-new-message/13606>\
**Category:** Android\
**Created:** [July 24, 2019, 12:42pm UTC](https://discuss.kotlinlang.org/t/how-to-refresh-or-update-recycle-view-every-time-with-new-message/13606 "2019-07-24T12:42:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![subhankar2028](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@subhankar2028](https://discuss.kotlinlang.org/u/subhankar2028)\
**Post date:** [July 24, 2019, 12:42pm UTC](https://discuss.kotlinlang.org/t/how-to-refresh-or-update-recycle-view-every-time-with-new-message/13606/1 "2019-07-24T12:42:09Z")

</div>

I am trying to refresh or update a recycle view every time then I get a new message.  
every time when i get a new message, then I update a list with the new message and then I want to update the recycle view by that list.

related class structure are given below. Please check.  
I am new to Kotlin and android development, so Please help me to solve the challenge.

* * *

## MainActivity Class

```
class MainActivity : AppCompatActivity(),UpdateRecycleView{
override fun refreshRecycleView(msg: String){
		//I am calling this function "refreshRecycleView" in some other class where I get MQTT message
		//this function can successfully call "onReceinveMQTTmessage"
		//now I want to "refresh or Update" the recycle view with the "MQTTmessage" which falls in this function through the arguement "msg"
		//How can I call the Adapter here to create the recycle view

```

}  
override fun onCreate(savedInstanceState: Bundle?){}  
}

* * *

## MainAdapter Class

```
class MainAdapter(val context: Context, item_list_str : String) : RecyclerView.Adapter<MainAdapter.MyViewHolder>() {
val item_list = item_list_str
var output_lst: List<String> = item_list.split("," ).map { it.trim() }
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {}
override fun getItemCount(): Int {}
override fun getItemViewType(position: Int): Int {}
inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
    var seek_val = 0
    var seek_tag = ""
    var currentTitle: String? = null
    var currentPosition: Int = 0
    init {}
}

```

}  
class CustomViewHolder(val view : View) : RecyclerView.ViewHolder(view){  
}
