Friday, 14 July 2017

ORDER COFFEE INITIAL HALF CODE

<?xml version="2.0" encoding="utf-8"?><LinearLayout    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:orientation="vertical"    tools:context=".MainActivity">

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

    <Button        android:id="@+id/button3"        android:layout_width="48dp"        android:layout_height="48dp"        android:onClick="increment"        android:layout_marginBottom="16dp"        android:layout_marginLeft="16dp"        android:text="+" />

    <TextView        android:id="@+id/quantity_text_view"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginBottom="16dp"        android:layout_marginLeft="16dp"        android:text="0"        android:textColor="#000000"        android:textSize="16sp"/>

    <Button        android:id="@+id/button4"        android:layout_width="48dp"        android:layout_height="48dp"        android:onClick="decrement"        android:layout_marginLeft="16dp"        android:text="-" />

    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginStart="16dp"        android:layout_marginTop="16dp"        android:text="price"        android:textAllCaps="true"/>
    <TextView        android:id="@+id/price_text_view"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="16dp"        android:layout_marginTop="16dp"        android:text="$0"        android:textColor="#000000"        android:textSize="16sp"/>

    <Button        android:id="@+id/button"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginLeft="16dp"        android:layout_marginTop="16dp"        android:onClick="submitOrder"        android:text="order"        android:textAllCaps="true"/>

</LinearLayout>



JAVA CODE FOR COFFEE ORDER

package com.example.android.justjava;

/** * IMPORTANT: Add your package below. Package name can be found in the project's AndroidManifest.xml file. * This is the package name our example uses: * <p>
 * package com.example.android.justjava; */

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

import java.text.NumberFormat;

/** * This app displays an order form to order coffee. */public class MainActivity extends AppCompatActivity {

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    /**     * This method is called when the order button is clicked.     */    public void increment(View view) {
        int quantity = 3;
        display(quantity);
        displayPrice(quantity * 5);

    }
    public void decrement(View view) {
        int quantity = 1;
        display(quantity);
        displayPrice(quantity * 5);


    }
    public void submitOrder(View view) {
        int quantity = 2;
        display(quantity);
        displayPrice(quantity * 5);
    }

    /**     * This method displays the given price on the screen.     */    private void displayPrice(int number) {
        TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
        priceTextView.setText(NumberFormat.getCurrencyInstance().format(number));
    }

    /**     * This method displays the given quantity value on the screen.     */    private void display(int number) {
        TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
        quantityTextView.setText("" + number);
    }
}

SCREEN SHOT

Thursday, 13 July 2017

Code For The Happy Birthday App Final Project Lesson 3


<?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"    tools:context=".MainActivity">


    <ImageView        android:src="@drawable/happybirthday"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:scaleType="centerCrop"        />
    <TextView        android:text="Happy B'day Bharath"        android:fontFamily="sans-serif-light"        android:layout_width="wrap_content"        android:textColor="#ffffff"
        android:layout_margin="20dp"        android:layout_height="wrap_content"        android:textSize="36sp"/>

    <TextView        android:text="From, Sambhav!"        android:fontFamily="sans-serif-light"        android:layout_width="wrap_content"        android:layout_alignParentBottom="true"        android:layout_alignParentRight="true"        android:layout_margin="20dp"        android:textSize="36sp"        android:textColor="#ffffff"        android:layout_height="wrap_content" />

</RelativeLayout>


Code For The The Happy Birthday Project

<?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"    tools:context=".MainActivity">


    <ImageView        android:src="@drawable/happybirthday"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:scaleType="centerCrop"        />
    <TextView        android:text="Happy Birthday Bharath"        android:layout_width="wrap_content"        android:textColor="#ffffff"        android:layout_height="wrap_content"        android:textSize="24sp"/>

    <TextView        android:text="From Sambhav"        android:layout_width="wrap_content"        android:layout_alignParentBottom="true"        android:layout_alignParentRight="true"        android:textSize="24sp"        android:textColor="#ffffff"        android:layout_height="wrap_content" />

</RelativeLayout>



Initial Code For Happy Birthday App

<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"
tools:context=".MainActivity">
<TextView
android:text="Happy Birthday YOURFRIENDHERE" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

Monday, 10 July 2017

Discussion about Constraint Layout

Before starting on the next video, we want to bring to your attention a new feature in new Android Studio - Constraint Layout - that may require you to make some code modifications to the steps you see in the following videos.

Keeping up with the changes

Google is constantly improving the Android platform and adding new features. This is great for you as a developer, but it makes learning harder sometimes. Recently Google released ConstraintLayout; a tool that makes it super fast to create responsive UIs with many different types of components. ConstraintLayout is a great tool to have on the sleeve, but for this class, we will use RelativeLayout, LinearLayout simpler.
All of this matters to you because the new project templates in Android Studio now use ConstraintLayout as default, which makes the code you see on your computer a bit different from what is on the screen.

Current Layout File

In the new versions of Android Studio, after choosing the Empty Activity template, the layout file app/src/main/res/layout/activity_main.xml will look like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.udacity.myapplication.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintLeft_toLeftOf="@+id/activity_main"
        app:layout_constraintTop_toTopOf="@+id/activity_main"
        app:layout_constraintRight_toRightOf="@+id/activity_main"
        app:layout_constraintBottom_toBottomOf="@+id/activity_main" />

</android.support.constraint.ConstraintLayout>
Note the use of ConstraintLayout, and that TextView has a list of limiters that position it within ConstraintLayout.

Modify the Layout File

Unlike the above code, our videos and start code assume that the template looks more like the following, using as the root of the view a RelativeLayout:
<?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.udacity.myapplication.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />
</RelativeLayout>
When you create your new project, go to app/src/main/res/layout/activity_main.xml and copy and paste the above code. Then you're ready to go!
If you want to understand more about the great features that ConstraintLayout provides, check out the documentation at: https://developer.android.com/studio/write/layout-editor.html

Wednesday, 28 June 2017

Default Constraint Layout Android SDK

<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="com.example.android.happybirthday.MainActivity">

    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Hello World!"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintLeft_toLeftOf="parent"        app:layout_constraintRight_toRightOf="parent"        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>


Tuesday, 27 June 2017

Discussion about Constraint Layout

Before starting on the next video, we want to bring to your attention a new feature in new Android Studio - Constraint Layout - that may require you to make some code modifications to the steps you see in the following videos.

Keeping up with the changes

Google is constantly improving the Android platform and adding new features. This is great for you as a developer, but it makes learning harder sometimes. Recently Google released ConstraintLayout; a tool that makes it super fast to create responsive UIs with many different types of components. ConstraintLayout is a great tool to have on the sleeve, but for this class, we will use RelativeLayout, LinearLayout simpler.
All of this matters to you because the new project templates in Android Studio now use ConstraintLayout as default, which makes the code you see on your computer a bit different from what is on the screen.

Current Layout File

In the new versions of Android Studio, after choosing the Empty Activity template, the layout file app/src/main/res/layout/activity_main.xml will look like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.udacity.myapplication.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintLeft_toLeftOf="@+id/activity_main"
        app:layout_constraintTop_toTopOf="@+id/activity_main"
        app:layout_constraintRight_toRightOf="@+id/activity_main"
        app:layout_constraintBottom_toBottomOf="@+id/activity_main" />

</android.support.constraint.ConstraintLayout>
Note the use of ConstraintLayout, and that TextView has a list of limiters that position it within ConstraintLayout.

Modify the Layout File

Unlike the above code, our videos and start code assume that the template looks more like the following, using as the root of the view a RelativeLayout:
<?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.udacity.myapplication.MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" />
</RelativeLayout>
When you create your new project, go to app/src/main/res/layout/activity_main.xml and copy and paste the above code. Then you're ready to go!
If you want to understand more about the great features that ConstraintLayout provides, check out the documentation at: https://developer.android.com/studio/write/layout-editor.html