Android Programming Tutorials

(Romina) #1
Browsing Some Posts


  1. All of the click-able items show up in blue underlined text, and
    when clicked they pop up the appropriate application (e.g., clicking


a Web URL brings up the Browser application).



  1. Clicking on a row with a location, as we introduced in a previous


tutorial, does not spawn our StatusMap.


Step #2: Draft and Package the Help HTML


Next, we need some placeholder HTML to serve as our help prose. This


does not need to be terribly fancy – in fact, simpler HTML works better,


because it loads faster.


So, write a Web page that will serve as the placeholder for the Patchy help.


The key is where you put the page: create an assets/ directory in your


project and store it as help.html in there. That will line up with the URL we


will use in the next section to reference that help file.


Step #3: Create a Help Activity


Now, we can create a help activity class that will load our Web page and do


some other useful things.


First, create Patchy/res/layout/help.xml with the following content:


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<WebView android:id="@+id/webkit"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1"
/>
</LinearLayout>

Then, create Patchy/src/apt/tutorial/two/HelpPage.java with the following


code:


252
Free download pdf