Difference between revisions of "Basic Android"

esse quam videri
Jump to: navigation, search
(Android Basics)
(Basics)
Line 23: Line 23:
 
==Basics==
 
==Basics==
  
*src folder containg all the source
+
*src folder containing all the source
 
*res folder containing all the resources
 
*res folder containing all the resources
 +
 +
folder hierchy explained @http://developer.android.com/training/basics/firstapp/running-app.html
  
 
==Resources==
 
==Resources==

Revision as of 17:42, 6 November 2012


Android Basics

after installing the plugin you may need to change the path to the SDK there is currently a bug if you us a folder with a space in the name use C:\PROGRA~2\Android\android-sdk if you installed to "C:\Program Files (x86)\Android"

Basics

  • src folder containing all the source
  • res folder containing all the resources

folder hierchy explained @http://developer.android.com/training/basics/firstapp/running-app.html

Resources

No DPI or PPI Andoid uses dp density independent pixels or sp scale interdependent pixels http://developer.android.com/guide/topics/resources/more-resources.html#Dimension

also see supporting multiple screens http://developer.android.com/guide/practices/screens_support.html

Activities

Activity life cycle http://developer.android.com/guide/topics/fundamentals/activities.html#Lifecycle

Get an instance of an object from the R class

<java>/** Called when the activity is first created. */

   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
       
       //Get the Button and the TextView from the Resource class
       Button btn = (Button)this.findViewById(R.id.button1);
       final TextView tv = (TextView)this.findViewById(R.id.textView1);  
       String s = "hello";
       tv.setText(s);
   }

</java>

notice the cast to the type also notice that the TextView is marked as final 
this is so that we can use it in an inner method

handle a click event <java> btn.setOnClickListener(new View.OnClickListener() {

@Override public void onClick(View v) { // TODO Auto-generated method stub tv.setText(d.About()); } });</java>

Events

Lots more good reading http://developer.android.com/guide/topics/fundamentals.html


This text will be replaced