I need to show some data in TextViews.But data may vary.So i need to add TextViews Dynamically.Can anyone tell me how to show to do this?
below is part of my xml file.Initially i have some textviews in the file.I need to add sometextviews some times.
Find the ViewGroup you want to add the TextView to, create the TextView, and add it to the ViewGroup, and if the ViewGroup is already visible you will need to re-validate it to force it to show the new data. You should already know how to get the ViewGroup you want, and you can read the API on how to create a TextView and add it to the ViewGroup. Note, you mat also need to force the layout to happen again if there is not enough room for the new TextView and the ViewGroup was already visible.
A question you should ask yourself, though: Are you sure you want to build the layout in code? Or do you think you could make different layouts in XML and choose which one is appropriate to display depending on the data?
sam liyanage wrote:actually in my table there are 7 fixed columns.But the number of rows may differ.So i am unable to fixed the rows.Then i need to add rows programtically.So Steve can you help me to do this?
Have you read the API? Have you tried to code it? What is the problem you are having?
I don't think you can use the normal LayoutParams for things that go in the table, because they don't know how to line up with the TableView's grid. For the TableRow you need to use TableLayout.LayoutParams and for the elements you put in the TableRow you need to use TableRow.LayoutParams.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop