Just Java Final Code With No Errors With No U.I

JUST JAVA
JAVA CODE

 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 {
int quantity = 0;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

/** * This method is called when the plus button is clicked. */ public void increment(View view) {

quantity = quantity + 1;
display(quantity);

/** * This method is called when the minus button is clicked. */ }
public void decrement(View view) {

quantity = quantity - 1;
display(quantity);



}
public void submitOrder(View view) {

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);
}
}

XML 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>

My Trial With Coffee Ordering App

<?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">

<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="5dp" android:paddingRight="5dp" >

<ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/images" android:scaleType="centerCrop" andr android:layout_gravity="top" />
<android.support.v7.widget.LinearLayoutCompat android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">
<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"/>

</android.support.v7.widget.LinearLayoutCompat>


</RelativeLayout>

</LinearLayout>


JAVA CODE

 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 plus button is clicked. */ public void increment(View view) {
int quantity = 2;
quantity = quantity + 1;
display(quantity);

/** * This method is called when the minus button is clicked. */ }
public void decrement(View view) {
int quantity = 2;
quantity = quantity - 1;
display(quantity);



}
public void submitOrder(View view) {
int quantity = 5;
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);
}
}

debugger sentence formation

We&#39;re making really good progress so
far.
As we continue to build
more challenging things for
our app, we&#39;re going to have to
improve our debugging skills.
In this video,
we&#39;re going to learn about how to
use a tool called the debugger.
We&#39;ll access the debugger
using Android Studio.
And the debugger is meant to help us
identify and fix errors in our code.
The great thing about the debugger is
that we can pause the app at a certain
point in time, and then we can inspect
the whole state of the app more closely.
Normally, when the app is
running on our device,
all the code gets executed very rapidly.
Within milliseconds, it can respond
to button clicks, update the screen,
calculate the price, and etc.
But with the debugger, we can pause at
a specific line of code in our app,
then we can step through our code line
by line as quickly or slowly as we want.
If you want to learn more techniques on
how to debug your app in Android Studio,
just search for
debugging Android Studio.
This first link is good.
It&#39;s a developer.android.com page, and
it has a bunch of techniques
on how to debug your app.
Together, we&#39;re going to learn
about how to work with breakpoints.
After this course,
you can always come back to this
page to refresh your memory.
In this exercise I want to show you
that your Android device does run
each line of code one at a time
from top to bottom within a method.
We&#39;ll also verify that clicking on the
plus button does trigger the increment
method, and clicking on the minus button
does trigger the decrement method.
First add something
known as a breakpoint.
A breakpoint marks
a specific line of code
where the debugger should
pause when it reaches here.
The red circular dot indicates
that the breakpoint is
on this line on 25 of
our main activity file.
You can add breakpoints to as many
places as you want in your code.
But for now,
I&#39;m just going to add one on the first
line of the increment method.
Then I can hit this bug icon
to run the app in debug mode.
The app will only pause on these
breakpoints when the app is running
in debug mode.
If you run the app normally
with this green play button,
then it won&#39;t pause
at these breakpoints.
For a brief moment, on the device,
you may have seen a dialog that says,
waiting for debugger.
There&#39;s also a button to force close
the app, but don&#39;t click on that.
Just wait for the debugger to attach and
the message will go away soon.
Then the app starts like normal and
you can interact with it.
Now, in debug mode, this window will pop
up and show the status of the debugger.
If you don&#39;t see it, you can click
on this tab down here called debug.
If I hit this plus button here, I expect
the increment method will be triggered
and that the app will
pause at this breakpoint.
Let&#39;s see what happens.
Cool.
It stops there.
In the debug pane,
we see a list of variables.
This reflects the current state
of the app where it was paused.
We don&#39;t see our quantity variable yet,
because it hasn&#39;t finished
executing this line of code yet.
There&#39;s a bunch of options on
how to proceed with debugging.
But I&#39;m going to click on this
option that says step over.
This will step over the current line
of code to the next line of code.
Now the app is currently
paused at line 26.
We finished executing line 25,
so that&#39;s why we see the quantity
variable showing up down here.
This list of variables also shows
the current value of each variable.
We can also verify that the quantity
variable has a value of 3,
which we assigned up here.
We know that the app is
currently paused at this point,
because normally when
you hit the plus button,
it would automatically
update the quantity to be 3.
But since the quantity is still a 2,
we know that it hasn&#39;t finished
executing the increment method yet.
We can click step over
to go to the next line.
At this point, the method is done.
And we&#39;re not really interested in how
it actually updates the screen, so
let&#39;s just hit resume program.
All we care about is that it
actually does update the screen.
If you&#39;re interested, you could have
clicked on these other options to look
at more details of how it
actually updates the screen.
At this point,
the app is running normally,
but the debugger is still attached.
So if I hit the plus button again,
it will stop at this breakpoint.
If I want to detach the debugger so that
it doesn&#39;t always stop on this line when
I hit the plus button, I can just
click on this red stop button.
Now whenever I hit the plus button,
it responds immediately and
updates the value to 3.
Now I want you to try
it on your computer.
Go ahead and add a breakpoint to
the increment and decrement methods.
Then run the app in debug mode,
and then on the device,
try to trigger each
of these breakpoints.
Then step through each line of code,
making sure that the quantity
variable shows up with the right
value in the variables list.
You can click on this play button
to resume execution of the app so
that it runs as normal.
Or you can hit the stop button
to detach the debugger.


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

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>

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

కరోనా కోవిడ్ -19 గురించి ఏ వికీపీడియా మీకు చెప్పలేము?

కరోనా కోవిడ్ -19 గురించి ఏ వికీపీడియా మీకు చెప్పలేము? మిమ్మల్ని మీరు రక్షించుకోండి  Your మీ చేతులను తరచుగా కడగాలి Eyes మీ కళ్ళు, న...