I am utilizing a version of the "Grid View" example from the Android Developers site:
http://developer.android.com/resources/tutorials/views/hello-gridview.html
And I would like to display a small text caption below each of the images.
Can someone please give an example of how this might be accomplished (i.e. what needs to be edited)?
Thanks!
Instead of an ImageAdapter returning ImageViews from getView(), you would need a TylerAdapter returning a LinearLayout or RelativeLayout for each cell, with the layout containing your ImageView and TextView caption.
Here is a free excerpt from one of books that illustrates stuff like this, albeit in the context of a ListView instead of a GridView. Those are both AdapterViews, and so the techniques are nearly identical.
Related
I'm using a RecyclerView to display a list of data from server. The data contain text and an uncertain number of urls of images with HTML tag. For each item, I'm now using HTML.fromHTML() with a ImageGetter to parse the data, get images and display them in a TextView. However, the images in TextView cannot interact with user. Events on the images like click, magnifying and save are not supported by TextView. And I tried using a Webview instead, but its performance is poor.
I also tried to write a compound view which extends a LinearLayout, and add TextViews and ImageViews dynamically (the number of images for each item are not certain), but it behaved strangely in the RecyclerView.
Is there any better idea or should I improve my solutions forementioned?
Thanks in advance!
The solution has been found by myself with the help of other programmers on StackOverFlow. For those who may see this question, please check Android - Custom dynamically-generated compound View recreated in RecyclerView, causing poor performance.
The idea is simple, creating a CompoundView extending LinearLayout which adds TextViews and ImageViews dynamically based on the data attached. Note that the processes of creating views and setting data for the them are seperate. For other details, please check the url above.
I am more familiar with web, but I am programming an Android app.
This is a beginner question, but I'm having trouble wrapping my head around reusable views in Android. On the web, I would create a partial view and pass parameters to be added via a templating language. What is the best way to do this on Android?
More specifically, I am trying to add a grid view where each slot of the grid has an image and a subtitle with a border. I want to dynamically load the image and subtitle from the database, and add an unknown number of images to the grid.
How could I create a view to hold the images and subtitles and then dynamically load them into the grid with different data?
Creating a GridView programatically:
http://www.codeproject.com/Questions/705639/how-to-create-gridview-in-android-programaticall
This should help you with the skeleton and you can add an ImageView and TextView as per your requirements.
How could I create a view to hold the images and subtitles and then dynamically load them into the grid with different data?
You need a GridView and an Adapter to load the items dynamically into your grid. I can't post the code actually here, because it would be a very long answer. But Here is a nice tutorial to get you started. In the example, there is a grid build with dynamic images showing step by step what you're looking for.
I am developing application which havely based on images. I am displaying these images in GridView like this picture.
But i want to make this text and image in together like following picture.
One solution is that Create an image with text together and display in gridview but it does not look clean solution. Kindly guide me, If android provides some nice and clean solution for this.
A GridView extends from AdapterView. An AdapterView is a view whose children are determined by an Adapter. An AdapterView uses a the getView() method to retrieve currently shown items.
You can customize this getView() method to return any kind of View.
e.g. a Relative Layout
This Relative Layout can contain an ImageView and a TextView
I hope this makes sense, if not comment below
i have a one arraylist in this textview is fixed with country name but images is not fixed it is 10,50,100 but first country name is display than all images which is created dyanmic imageview so is this possible with listview and this country name and images morethan 1 how to do with this listview i have done this with tablelayout but i have no idea about tablelayout lazy loading all lazy loading is for listview not for tablelayout so i want to ask is this possible in listview like tablelayout so i can dothis thanks in advace
HERE YOU CAN SEE IMAGE SO U CAN BETTER UNDERSTAND
As per the comments above:
The link to the GridView Layout: http://pastebin.com/DXfut3eM
The link to the custom GridView items: http://pastebin.com/57fC9uuk
The link to the Main Activity: http://pastebin.com/bft4uuRT
The link to the Adapter used as per Fedor's Lazy Load example: http://pastebin.com/dkP0NWju
Please note that I am not including links to the other files which are common to Fedor's example. They are pretty much the same with minor changes to suit my requirements. Use the stock files from his github and this will work exactly the same as mine.
Hope this helps and good luck.
In my application, I'm using a gridview to display images, but I want to display the text on the images. Is this possible? If so, how can I implement it?
Thanks.
Just give you a hint.
You must have seen "hello gridview" here: http://developer.android.com/resources/tutorials/views/hello-gridview.html
You just need to get a custom view (may be a LinearLayout) instead of a imageview in getview() in adapter.
Hope this help.