I am developing an app that need to display information on the stock of a store. Each activity will have upto 100 items.
My plan is to layout this information in a 10 * 10 grid. Each box in the grid represents an item of stock. Each of these items will be represented by an icon and a piece of text beneath the icon (the name). I setup a new layout which has an ImageView and a TextView for this. I called the layout Tab.xml
So, I need to know if it is possible to write a java class which will use the Tab.xml as the layout.
Then I can programmatically create each java class item, setting the image and text as I go along.
Can anyone please give me some direction about this?
That’s not recommended, unless the text and icons are really small. Even in a high density screen it won’t look too good.
Anyway, for what you want, you don’t need to write a class to render your views. You can use
GridViewwhich allows you to do it easily. Take a look at this tutorial: Creating a custom Adapter for GridView1. It’s just a matter of inflating yourTab.xmlin the custom adapter, and populate it with some data (maybe an array).