Android Programming Tutorials

(Romina) #1
Look Inside Yourself

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

Then, change it to be a ListActivity instead of an ordinary Activity, as we


will be using some ListActivity-specific methods and support in this


tutorial.


Step #2: Create the Photographer Layout.........................................


The goal of Contacter is to allow you to choose a contact, then show a list of


possible actions on that contact via a ListView. That means we need a layout


that lets us accomplish those ends.


With that in mind, create Contacter/res/layout/main.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"
>
<Button
android:id="@+id/pick"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Gimme a contact!"
android:layout_weight="1"
/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>

306
Free download pdf