Java files
Package Org.crazyit.helloworld;
Import Android.os.Bundle;
Import android.app.Activity;
Import Android.view.Menu;
Import Android.view.View;
Import Android.widget.TextView;
public class Helloworldactivity extends Activity
{
@Override
public void OnCreate (Bundle savedinstancestate)
{
Super.oncreate (savedinstancestate);
interface layouts defined using the Hello_world.xml file
Setcontentview (R.layout.hello_world);
}
@Override
public boolean Oncreateoptionsmenu (Menu menu)
{
Getmenuinflater (). Inflate (R.menu.hello_world, menu);
return true;
}
public void ClickHandler (View source)
{
Gets the text box with ID r.id.show in the UI interface
TextView TV = (TextView) Findviewbyid (r.id.show);
Change the text contents of a text box
Tv.settext ("Hello android-" + New Java.util.Date ());
}
}
XML file
<relativelayout
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Xmlns:android= "Http://schemas.android.com/apk/res/android"
xmlns:tools= "Http://schemas.android.com/tools" >
<textview
Android:id= "@+id/show"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:layout_centerinparent= "true"
Android:layout_alignparenttop= "true"
Android:textsize= "20SP"
android:text= "@string/hello_world"/>
<button
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_below= "@id/show"
android:text= "Click Me"
android:onclick= "ClickHandler"
/>
</RelativeLayout>
The first Android app--Starting with HelloWorld