Tag Archives: textview

Basic GUI programming in android

how to -

  1. layout?
  2. textbox?
  3. button?
  4. new activity?
  5. strings?
  6. communication between activities?

Best features in eclipse adt/android

  1. res/layout/main.xml Graphic layout
  2. res/values/strings.xml Resources
  3. Amazing debugger and intellisense
  4. Packages: http://developer.android.com/reference/packages.html i would like to quote starting android.widget.TextView and android.widget.EditText
  5. My first edittext widget(textbox control) set/get
    EditText txtName;
    txtName = (EditText)findViewById(R.id.txtName);
    txtName.setText('0');
    txtName.getText();

    http://www3.ntu.edu.sg/home/ehchua/programming/android/Android_BasicsUI.html

  6. My first button click
    Button button = ((Button)findViewById(R.id.btnSave));
    button.setOnClickListener(new View.OnClickListener(){
    	public void onClick(View v){
    	// Perform action on clicks
    	}
    });
  7. anonymous object of an interface with a method!
    the beauty of this piece of code is, OnClickListener is an interface
    http://www.jameselsey.co.uk/blogs/techblog/binding-your-buttons-to-your-activity-the-easy-way/
  8. My first toast(message box)
    Toast.makeText(HelloAndroidActivity.this, '...', Toast.LENGTH_SHORT).show();
  9. A new activity class for every window, appending the res/AndroidManifest.xml
  10. Layouts prety confusing, i went with just the knowledge of the default Vertical linear layout adding widgets one below the other

The GUI programing in android

  1. layers – presentation layer has a GUI editor where u can add presentation controls and edit their id’s which get stored on an xml version. awesome is this xml gets converted to a java class automatically. in the programing layer, the fascinating cross layer function findobjectbyid is used – the object equvalent is derived here
  2. manipulations and access – using the object get and set methods can be used
  3. abstraction – what cant be seen here is the moment the activity class was extended with it must come events which paint the screen after events and such thus bringing to light our changes made in step 2! – totally essential to understand the flow of architecture
  4. wow – on the create event we bind a function to on-click of a button such that it does not execute then at that point but executes when the button is clicked, awesome.

The layout.xml is not scary anymore, to an extent I have started to read it successfully.

next up – database, lists/buttons/dynamic programming and communicating between activities