开发者

views in tab not getting displayed after database update

I am using two tabs in my android application.

In Tab A, the user enters some values and a database is updated based on the entered values.

In Tab B, I am trying to display the updated values of the database using TextViews.

But when I switch from Tab A to Tab B after entering the values in Tab A 开发者_如何学C(i.e. after updating the database), the Tab B appears empty.

Only when I restart the app, the Tab B appears correctly with updated values.

Please suggest to me what could be the problem...


In Tab B's Activity you should put code that loads data from database and displays it, inside .onResume() method.

Check Activity Lifecycle document to see what lifecycle methods are run at what lifecycle stages.


Posting your code could be helpful as we can't tell from your post if you are using tab activities or tab view, but either way it sounds as if you aren't refreshing the data. You need to figure out the correct event and actually reload the text of the TextViews. When you are restarting your application, it is loading everything from the database, and so you see all the correct data, but when you update the data, all the widgets have already been populated, and there isn't anything that tells them that the database actually changed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜