satya
satya

Reputation: 27

Dynamically added views in linearlayout

Dynamically I am creating the linear layout and adding the views to linear layout every 5 sec I need to update data to linear layout from database . But When I checked the log output it is adding to linear layout but gui is not getting updated for every 5 sec. I am using scheduled fixed timer task . What should i do ?

Upvotes: 0

Views: 1226

Answers (2)

dweebo
dweebo

Reputation: 3272

I agree w/ the other answer from Dimitar that you probably don't want to do this with a linear layout.

However if you must, are you calling invalidate() on the LinearLayout after adding a new view to it?

Upvotes: 1

Dimitar Dimitrov
Dimitar Dimitrov

Reputation: 16357

If you want to visualize data in your application, you should adapt this data to the UI component that will display it. LinearLayout doesn't sound like a good choice for what you are trying to do.

Most often, in Android this is done by using a subclass of BaseAdapter and displaying the data in a subclass of AdapterView. Changes in the adapted data should be handled by the adapter, and the UI component should be updated accordingly.

If you are using SQLite database, take a look at the classes Cursor and CursorAdapter.

Upvotes: 1

Related Questions