Tabbed Browsing, Sort Of
One of the main features of the modern desktop Web browser is tabbed browsing, where a single browser window can show several pages split across a series of tabs. On a mobile device this may not make a lot of sense, given that you lose screen real estate for the tabs themselves.
In this book, however, we do not let little things like sensibility stop us, so let me demonstrate a tabbed browser, using and .
As you may recall from Chapter 10, a tab can have either a or an as its content. If you want to use an as the content of a tab, you provide an that will launch the desired ; Android’s tab‑management framework will then pour the ’s user interface into the tab.
Your natural instinct might be to use an the way we used a in the previous example:
New Intent
SetData parse
That way, you could use the built‑in Browser application and get all of the features that it offers.
Alas, this does not work. You cannot host other applications’ activities in your tabs – only your own activities, for security reasons.
So, we dust off our demos from Chapter 13 and use those instead, repackaged as .
Here is the source to the main activity, the one hosting the :
Public class extends
Public onCreate
Super onCreate
GetTabHost
AddTab newTabSpec setIndicator
SetContent new Intent this class
Дата добавления: 2015-05-16; просмотров: 680;