create tabbed view to display web pages - android

In my app I am making a web browser in which I want to show different pages in form of tabs. I want to create a view like this
But I have no idea how to do this. Need guidance regarding the components required.

Well the "simple" way to achieve this would be to create an adapter of some sort that overrides the getView() function to create a WebView
and return it as one of the items. The URL of this webview can be mapped to an array or cursor. Since a WebView is a very costly component, you will need to implement the ViewHolder pattern to ensure the webviews are recycled properly.
A lot more work is required to get the rounded corners plus the extra top features but hopefully this can get you started on the right track.

Related

Correct design for using the same data for different views

I am new in the corporate world & from design perspective please correct me if I am doing something wrong here
I am fetching images from Flickr API.
GOAL: Show these images in two different type of view, grid view and listview. Which can be switch through the slide.
So I am using a View pager with two fragments and both of these fragments has separate listeners. So when the response came from Flickr both of these listeners are notified.
In my opinion, this saves two times calling of REST API, but I am looking for even more efficient design or flow through which
Using single listener
Rest API should be called once
Result should be store (Just in ArrayList) and share to both of views
May not choosing two separate fragments
Avoid creating Adapter object two times
Image should be stored in cache
Any tweak or suggestions will be helpful a lot, please comment if you don't understand any part or whole question.
For above problem, the tweaking you are thinking is almost right. Other than below:
What I believe you must create two different adapters to have more control over different views. For example, you might want to show with scale type crop center for an image in list view but scale type center inside for an image in grid view. There might be the different type of thing you may want to perform. So, it's a good practice to make two different adapters, to make the code more manageable.
Again the same goes for the fragment, see if actions in both the fragments are same or can be done with single variable passing. Then only go with a single fragment.
Rest of the things are perfect.

Android dynamically creating UI v. ListView

I have an android app that I'm developing using Xamarin. The app contacts the server and, via web service (SOAP), receives a list of objects. Currently, in my axml file I have just linear layout (ll) within scrollview tags and nothing else. In the code, I loop through the collection and new up the elements that I want and attach it to a layout. Once I'm done with each record, I attach (i.e.AddView) to the master layout (ll). Everything works.
I have a couple of concerns and I appreciate some feedback on it.
1) Each object in the list contains an URL to an image online. Currently, for each object, my process downloads the picture individually. Would ListView give me any advantage of reusing (caching , etc.) an already downloaded picture even though other attributes of the objects are different? Will there be any gain in terms of network utilization if I switch to ListView?
2) Is drawing elements by hand (like I'm doing) an acceptable best-practice?
Thanks all.
Definitely use a ListView. There is a great article here by Lucas Rocha that outlines exactly why ListViews are beneficial and how to make them perform even better. To give you a few examples, ListViews minimize the number of view inflations you do, and they only create the list items currently visible on the screen or about to become visible on the screen.
This is a huge improvement from your approach, since your current method would load every element in the list before presenting the activity to the user. Therefore, drawing elements by hand like you're currently doing is definitely not best-practice.
Also, for displaying images from URLs in your Xamarin app, I highly recommend that you use the Xamarin component UrlImageViewHelper. Despite being incredibly easy to implement in your app, it will improve performance drastically since it takes care of image caching and async image loading.

Android Displaying data on gridview

I have some data in my data base and i want to display it in android phone.I want to display my data on Grid-view because there is continuous variation in my data therefore i want to display in android like asp.net gridivew.Please anyone help me to do this or any example code to do this
You need to have two things for the Gridview:
Use Gridview component in a layout.
Inflate the elements in a getView method and set elements position by position to the Gridview items.
You can follow this link to understand it:
http://android-coding.blogspot.in/2011/09/simple-gridview-example.html
You are on the right track as you have decided yo use a dynamic view for your varying data. You can use any one of the dynamic view(list view, grid view, gallery, etc) depending on the kind of data you need to display.
If you are not familiar with these dynamic views then you should first go through some tutorials on implementation of these views. First try with a basic program for understanding the concepts. Once you are clear with the concepts then all you need to do is to replace the underneath data with the data fetched from the data base.
There are lots of tutorial available on net. Here are some links:
GridView tutorial
ListView tutorial
Feel free to discuss in case there is any doubt.

android fragment inside listview

my app is a social network where users share links and tag them to let the right persons receive it. Basically, the main activity is simply a listview of posts. I use an open protocol parser to get the web objects metadata on server side.
Now I need to display the right layout in each post item depending of the metadata (video, app, web page, ...). And of course, layouts must react to user clicks event and call intents.
So my first idea is to have a framelayout for each item where I load a specific fragment in charge of generating the right layout depending of the resource type.
But I'm really not sure loading a fragment inside a listview item is a good practice as the reuse system of views is totally messed up.
I'd just like to know what is the best way to implement this functionality for you guys.
Thank you.
This is not really what fragments are designed for. You do not need to use fragments to have ListView rows of differing types -- just override getItemViewType() and getViewTypeCount() in your ListAdapter, then be sure to create the right type of row on demand based upon the metadata.

Android tabs with views, still dynamic

I want to avoid using intents in android tabs. so I am doing views, but I would like an example on how a large project does this.
Mainly because I am not just displaying static information configured on the view xml, but I am pulling a lot of information from a server when a user interacts with a button within a view. The code seems like it can get really long and messy with this view implementation, instead of when each view is in a separate activity.
I would like to see how others separated their methods in a nice neat and organized way.
and that example hello-tabwidget is nowhere near what I am looking for, thanks
use a viewflipper. its like the text switcher. u put a layout inside of a viewflipper and trigger it wen a tab is selected.
http://www.warriorpoint.com/blog/2009/05/26/android-switching-screens-in-an-activity-with-animations-using-viewflipper/

Categories

Resources