0

I am creating Android application for an IOT product . I am uploading sensor data to an web serves developed in REST architecture. web service is working perfectly . I want show in real time that if sensor data changes. I want retrive data and update the Textview how can I do that?

  • Possible duplicate of [Updating the list view when the adapter data changes](https://stackoverflow.com/questions/4198425/updating-the-list-view-when-the-adapter-data-changes) – ADM Dec 01 '17 at 07:06

3 Answers3

0

For refreshing listview data,you need to use the following line of code,

adapter.notifyDataSetChanged();

where,

    adapter = your listview adapter object

Write above line of code after you retrieve data from a server or local database.

Yogesh Nikam
  • 633
  • 5
  • 20
0

You want to update a textview or a listview? If it is that you want to keep adding new records to a list view, just add the items to the listview adapter as they come in and call youradapter.notifyDataSetChanged() so the listview updates its content.

Cristian
  • 370
  • 3
  • 8
0

Add this Code in your adapter list like :

Adapter_Constructer(List<String> data){
this.data=data;
notifyDataSetChanged();}

and then update it when u want

or just use :

adapter.notifyDataSetChanged();

in your response method.

or Reinitialize and reset adapter then call adapter.notifyDataSetChanged();