Question

Does anyone know of any good tutorials that show how to create tabs with listviews as content? Possibly also showing how to update lists on tab focus?

Was it helpful?

Solution

By clicking on a tab you are supposed to start an Activity. You simply fire off an Intent. What the Activity you start does and how it looks like is totally up to you.

If you start an Activity through a tab click then the default Android Activity life cycle kicks in which means that you can implement your list updating logic somewhere in onCreate() if appropriate for you.

I highly recommend reading up the articles and tutorials on http://d.android.com as your main problem seems to be that you don't understand how Android is supposed to work.

OTHER TIPS

The android documentation at http://developer.android.com/resources/tutorials/views/hello-tabwidget.html states:

Tutorial snippet

To create a tabbed UI, you need to use a TabHost and a TabWidget. The TabHost must be the root node for the layout, which contains both the TabWidget for displaying the tabs and a FrameLayout for displaying the tab content.

You can implement your tab content in one of two ways: use the tabs to swap Views within the same Activity, or use the tabs to change between entirely separate activities. Which method you want for your application will depend on your demands, but if each tab provides a distinct user activity, then it probably makes sense to use a separate Activity for each tab, so that you can better manage the application in discrete groups, rather than one massive application and layout.

Maybe this is an outdated version and in higher android versions creating an activity is the cleanest way to accomplish this task, but in the documentation it states that it is also possible to handle Views instead of Activities.

Sadly the documentation only describes the possibility of handling Activites in its tutorial.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top