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
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.
Below is an image of GPS Essentials app, which I guess a lot uses.
I am interested in making a menu similar to this. How is such a menu (or what ever it is called) created.
My first thought was to use a ListView having elements containing an image and text-view in vertical orientation. But then I was wondering if there is any better, preferably an easier way to do it.
I would be very greatful if you could share your experience with me. Thank you.
GridView is the solution exactly. You have to actually define a custom adapter for the GridView.
Why custom adapter? Because you have to inflate a custom row (having ImageView and TextView) to every item in your GridView.
Hint: Search for the example with word "Android Gridview example", you will get many articles/tutorials.
use GridView. You can find documentation here http://developer.android.com/resources/tutorials/views/hello-gridview.html
I found the following design in market of my tablet. I want to design a layout as like the below tables containing a image, text and a button for my android app. how to do this
You can achieve simple table look, by setting different colors to rows and cloumns and set appropriate margins in that here is example. Here he sets only border but you can fill any color or drawable inside column.
For this solution, i would suggest you to design custom adapter to be displayed either in GridView or in multi column ListView.
But i think GridView would be best to implement the above functionality.
Now, to define a custom adapter, you just have to create a simple class and extends BaseAdapter, and then you have to override the getView() method inside this class. Now within the getView() method, you can inflate() the custom row layout file (which you define for one item , this item xml layout file represents every items inside the GridView).
Here is the simple example for implementing a simple GridView.
For the detailed exmmple of such gridview, refer this example: Android - GridView example
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.
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.