create and use variables

variable name java
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html

data type variable name = initial value
int numberOfCoffees = 2;
display(numberOfCoffees);
display(numberOfCoffees * 5);

DDMS stands for Dalvik Debug Monitor Server, and is a tool in Android to help you debug your app.
https://developer.android.com/studio/profile/ddms.html?utm_source=udacity&utm_medium=course&utm_campaign=android_basics
Debug, Crashes, Compile time error, Runtime error, System log, Stacktrace

debugging android studio
https://developer.android.com/studio/debug/index.html

int quantity = 2;
quantity = 3;
quantity = 4;
quantity = 5;

int quantity = 2;
quantity = quantity + 1;

Modify the button

Main Activity

package com.example.android.justjava;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	public void submitOrder(View view){
		display(1);
	}

	private void display(int number){
		TextView quantityTextView = (TextView) findViewById(
			R.id.quantity_text_view);
		quantityTextView.setText("" + number);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu){
		// Inflate the menu; this adds items to the action
		getMenuInflater().inflate(R.menu.menu_main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item){

		int id = item.getItemId();

		if ( id == R.id.action_settings){

		}
	}
}

getting paste error
1. read the error message
2. compare to working code
3. undo
4. ask for help

git hub gist

	private void displayPrice(int number){
		TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
		priceTextView.setText(NumberFormat.getCurrencyInstance().format(number));
	}

User Input

Select views
-2 TextViews, 1 Button

Position views
-Use LinearLayout as parent ViewGroup for these 3 children view set LinearLayout orientation to be vertical

Style views
-Quanity header should be in all caps
-Quantity value should be in black font color
-Add spacing between views

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android."
	xmlns:tools="http://schemas.android.com/tools"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:paddingBottom="@dimen/activity_vertical"
	android:paddingLeft="@dimen/activity_horizontal"
	android:paddingRight="@dimen/activity_horizontal"
	android:paddingTop="@dimen/activity_vertical"
	android:orientation="vertical"
	tools:context=".MainActivity">

	<TextView
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:layout_marginBottom="16dp"
		android:text="Quantity" 
		android:textAllCaps="true" />

	<TextView
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:text="0"
		android:textSize="16sp"
		adnroid:textColor="@android:color/black" />

 	<Button
   	 android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:layout_marginTop="16dp"
     android:text="Order" />

</LinearLayout>

button android
https://developer.android.com/reference/android/widget/Button.html

conversation list activity

Java file -> MainActivity.java

package com.example.android.justjava;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends ActionBarActivity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu){
		// Inflate the menu; this adds items to the action
		getMenuInflater().inflate(R.menu.menu_main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item){

		int id = item.getItemId();

		if ( id == R.id.action_settings){

		}
	}
}

comments java
http://journals.ecs.soton.ac.uk/java/tutorial/getStarted/application/comments.html

Drawing to code

step1: select the views
step2: position the views
step3: style the views

what view group should you use
-LinearLayout
-RelativeLayout : relative positioning, overlap

The drawable folder
android:src=”@drawable/androidparty”

Position the view
Style the view

Trouble shooting

android studio strouble shooting
https://docs.google.com/document/d/1w1Xn_hnSAODAAtdRDp7haYPBtEwX_l7Htpf8Wpgbu6w/pub?embedded=true

Linear layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:paddingBottom="@dimen/activity_vertical_margin"
	android:paddingLeft="@dimen/activity_horizontal_margin"
	android:paddingRight="@dimen/activity_horizontal_margin"
	android:paddingTop="@dimen/activity_vertical_margin"
	tools:context="com.xxx.myapplication.MainActivity">

	<TextView
		android:layout_width="wrap_content"
		android:layout_height="wrap_content"
		android:text="Hello world!" />
</RelativeLayout>

Relative Layout

top edge, left edge, right edge, buttom edge
relative to parent

android:layout_alignParentTop=”true”
android:layout_alignParentBottom=”false”
android:layout_alignParentLeft=”true”
android:layout_alignParentRight=”true”

<RelativeLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:padding="16dp">

	<TextView
		android:text="I'm in this corner"
		android:layout_height="wrap_content"
		android:layout_width="wrap_content"
		android:layout_alignParentBottom="true"
		android:layout_alignParentLeft="true" />

    <TextView
        android:text="No, up here"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true" />
 
    <TextView
        android:text="Wait, I’m here"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true" />
 
    <TextView
        android:text="Actually, I’m here"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true" />

</RelativeLayout>

Simple image view

<ImageView
	android:src="@drawable/cake"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:scaleType="center"/>
<ImageView
	android:src="@drawable/cake"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:scaleType="centerCrop"/>

textView android, use google search
https://developer.android.com/reference/android/widget/TextView.html

capitalize

<TextView
	android:text="Oh the possibilites of TextView"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:textSize="36sp"
	android:textAllCaps="false"/>

LinearLayout

<LinearLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content">

<TextView
	android:text="I'm a lonely TextView"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content" />

<TextView
	android:text="I'm a lonely TextView"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content" />

</LinearLayout>

android orientation
https://developer.android.com/reference/android/widget/LinearLayout.html

200dp, wrap_content, match_parent

wrap_content

<TextView
	android:text="wait, today's your birthday?"
	android:background="@android:color/darker_gray"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content" />

font size

<TextView
	android:text="wait, today's your birthday?"
	android:background="@android:color/darker_gray"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:textSize="56sp" />

appearance

<TextView
	android:text="wait, today's your birthday?"
	android:background="@android:color/darker_gray"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:textAppearance="?android:textAppearanceSmall" />

google design spec style color
https://material.io/guidelines/style/color.html

text color and background color

<TextView
	android:text="wait, today's your birthday?"
	android:background="#ECEFF1"
	android:textColor="#616161"
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:textAppearance="?android:textAppearanceSmall" />

Using a TextView

<TextView
	android:text="Happy Birthday!"
	android:background="@android:color/darker_gray"
	android:layout_width="150dp"
	android:layout_height="75dp" />

-weird angle brackets
-don’t know what “android:text” means
-says Happy Birthday which appears on phone

XML Syntax

<LinearLayout
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:orientation="vertical">

	<TextView
		android:text="Happy Birthday"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content" />

	<TextView
		android:text="You're the best!"
		android:layout_width="wrap_content"
		android:layout_height="wrap_content" />

</LinearLayout>

Attribute Name, Attribute value in “Quotations”
TextView has default values if you’re ok with default values, don’t set them here.

Android Fragment

Fragmentは、Activity でのユーザー インターフェースの挙動や部位を表すものです。 1 つのアクティビティに複数のフラグメントを組み合わせてマルチペインの UI をビルドしたり、複数のアクティビティでフラグメントを再利用したりできます。

TitlesFragment.java

package self.myfragmentapp;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.widget.ArrayAdapter;


public class TitlesFragment extends ListFragment {

    public TitlesFragment() {}

    @Override
    public void onActivityCreated(Bundle savedInstanceState){
        super.onActivityCreated(savedInstanceState);

        setListAdapter(new ArrayAdapter<String>(
                getActivity(),
                android.R.layout.simple_list_item_1,
                News.Titles
        ));
    }
}