It is because in this post, what we will introduce to you in Java code. Yes. It can also used for running on Android platform, without using XML-based layout. That's right! XML-based layout is the more common approach in Android developers. You will see them in later tutorials.
Let's go down the real business, shall we?
First of all, we need to create a new project in Eclipse Editor for this tutorial. To create a new project in Eclipse, select File > New > Project. This will trigger the file wizard for new project.



package edu.mobilestudent.firstAndroid; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import java.util.Date; /*Using Java to create a button. On Click Event will trigger date.*/ public class ShowTime extends Activity implements View.OnClickListener{ Button btn; @Override public void onCreate(Bundle icicle){ super.onCreate(icicle); btn = new Button(this); btn.setOnClickListener(this); updateTime(); setContentView(btn); } public void onClick(View view){ updateTime(); } private void updateTime(){ btn.setText(new Date().toString()); } } |

Well done. Your first experience with Android has been completed! Click on the screen and you will notice that the time will be updated.
To download the package, click on FirstAndroid.rar