aspose file tools*
The moose likes Android and the fly likes How to update rows in Table layout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "How to update rows in Table layout" Watch "How to update rows in Table layout" New topic
Author

How to update rows in Table layout

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hi all in my application I had created table layout. continuous Data is coming from server and this data is shown in table layout. Now if suppose server send data which changes one or more rows values in table layout then I want to update this in table layout. I don't know how much data I will get from server therefore I had created table layout programatically (dynamically). Now when some rows values changes then I can't find the reference of that particular row so I can't update particular rows values. The scenario is like this:

Suppose table layout looks like this:

Name empId MobNo
Pramod 123 12334
Tom 345 456465
Harry 345 546


But the challange is if suppose
server send data from Pramod again then it must override old value and
it look like


Name empId MobNo
Pramod 123 78978
Tom 345 456465
Harry 345 546


And if new record received then it must add new row as


Name empId MobNo
Pramod 123 12334
Tom 345 456465
Harry 345 546
Rob 4554 465456


How to do this? Any response is appriciated. Thanks in advance.




Life is easy because we write the source code.....
Riccardo Ci
Greenhorn

Joined: May 23, 2011
Posts: 3
I cannot see any clear system for updating data that is not removing all child and adding the new based on the new data received.
In my opinion it's better if you switch to a ListView: with a easy style-process you can get the same look&feel of a TableView and you can take advantage of the Adapter for updating data
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hi Riccardo Ci Thanks for reply. I had also tried with list view as :

>

But now what happened there is changes only in one row. Means suppose from server side there is change in one record then all records value is set to that changed record value.
Riccardo Ci
Greenhorn

Joined: May 23, 2011
Posts: 3
Hi! I think your code is partial and then i can suggest you directly the code.
As i can see you set the adapter is a cycle but you should populate the HashMap at and the end you create the Adapter and assign it to the ListView.

PS: To have a more flexible code i suggest you to use ArrayAdapter instead of SimpleAdapter ;)
 
 
subject: How to update rows in Table layout