Coding App Behavior

Code to give behavior to the layout is written and stored in the Java class file associated with the layout. Open the HelloWorldActivity.java file by double-clicking it. If it is already open, click its tab in the editor. You should see the basic code structure (Listing 3.4).

Listing 3.4 Initial Activity Code

                                                                      //1package com.example.helloworld;                                                                      //2import android.os.Bundle;import android.app.Activity;import android.view.Menu;                                                                      //3public class HelloWorldActivity extends Activity {    @Override ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.