Difference between revisions of "Basic Android"

esse quam videri
Jump to: navigation, search
(Dog Class in java)
(Android Basics)
Line 6: Line 6:
*Install 32 bit Java JDK http://www.oracle.com/technetwork/java/javase/downloads/index.html
*Install 32 or 64  bit Java JDK http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
*App Inventor Pretty basic web interface an blocks editor to build simple android apps http://appinventor.mit.edu/about/  
*App Inventor Pretty basic web interface an blocks editor to build simple android apps http://appinventor.mit.edu/about/  
Line 13: Line 13:
*Android SDK
*Android SDK
**Install SDK Installer http://developer.android.com/sdk/tools-notes.html
**Download Android Studio
***Install to c:\android to avoid folder name issues on windows
**For SDK path we will use c:\user\Android
**Install Eclipse http://www.eclipse.org/downloads/ Eclipse Classic 32 Bit
**Install Eclipse ADT Plugin http://developer.android.com/sdk/eclipse-adt.html#installing
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"
*Android NDK
*Android NDK

Revision as of 17:55, 10 November 2015

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


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


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. */

   public void onCreate(Bundle savedInstanceState) {
       //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";


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>


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


Dog Class in java

public class Dog {

	public String Name;
	public int Weight;
	public String BarkSound;
	public Dog()
		this.Name = "fido";
		this.Weight = 1;
		this.BarkSound = "woof";
	public void Eat()
	public void Poop()
	public String About()
		return String.format("Hello my name is %s. I weigh %s lbs",	
				this.Name, this.Weight);