// ******************************************************************* // // ** Chapter 2 Code Listings ** // // ** Professional Android 2 Application Development ** // // ** Reto Meier ** // // ** (c)2010 Wrox ** // // ******************************************************************* // // ******************************************************************* // ** Listing 2-1: Hello World package com.paad.helloworld; import android.app.Activity; import android.os.Bundle; public class HelloWorld extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } } // ******************************************************************* // ** Listing 2-2: Hello World layout resource // ******************************************************************* // ** Listing 2-3: Creating layouts in code public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); LinearLayout.LayoutParams lp; lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); LinearLayout.LayoutParams textViewLP; textViewLP = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout ll = new LinearLayout(this); ll.setOrientation(LinearLayout.VERTICAL); TextView myTextView = new TextView(this); myTextView.setText("Hello World, HelloWorld"); ll.addView(myTextView, textViewLP); this.addContentView(ll, lp); } // ******************************************************************* //