About us Contact us privacy policy

Sunday, February 17, 2019

just java coffee App

"You are two cups away from free drink" I just liked this statement : )


App progress.



JAVA CODE for MainActivity

/** * IMPORTANT: Make sure you are using the correct package name.  * This example uses the package name: * package com.example.android.justjava * If you get an error when copying this code into Android studio, update it to match teh package name found * in the project's AndroidManifest.xml file. **/
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 numberOfCoffees = 2;


    @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 submitOrder(View view) {
//        display(numberOfCoffees);  //      displayPrice(numberOfCoffees * 5);
        String pricetext = " You've won a free Gift ";
        displayMessage( pricetext );
    }

    public void increment(View view){
        numberOfCoffees = numberOfCoffees + 1;
        display(numberOfCoffees);
        displayPrice(numberOfCoffees * 5);
    }

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

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


    /**     * 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 text on the screen.     */    private void displayMessage(String message) {
        TextView priceTextView = (TextView) findViewById(R.id.price_text_view);
        priceTextView.setText(message);
    }




}













XML CODES FOR activityMain



<?xml version="1.0" encoding="utf-8"?><RelativeLayout 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"    android:padding="16dp"    tools:context=".MainActivity">

    <TextView        android:id="@+id/quantity"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:paddingTop="16dp"        android:text="Quantity!"        android:textAllCaps="true"        android:textColor="@color/colorPrimary"        android:textSize="20sp" />


    <Button        android:id="@+id/increment_button"        android:layout_width="40dp"        android:layout_height="wrap_content"        android:layout_below="@id/quantity"        android:layout_marginLeft="17dp"        android:layout_marginTop="0dp"        android:layout_marginRight="16dp"        android:layout_toRightOf="@+id/quantity_text_view"        android:onClick="increment"        android:text="+" />

    <TextView        android:id="@+id/quantity_text_view"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/quantity"        android:paddingLeft="56dp"        android:layout_marginTop="8dp"        android:paddingTop="0dp"
        android:text="0"        android:textColor="@android:color/black"        android:textSize="20sp" />


    <Button        android:id="@+id/decrement_button"        android:layout_width="40dp"        android:layout_height="wrap_content"        android:layout_below="@id/quantity"        android:layout_marginLeft="0dp"        android:layout_marginTop="0dp"        android:onClick="decrement"        android:text="-"        android:textSize="20sp" />


    <TextView        android:id="@+id/price"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@+id/quantity_text_view"        android:paddingTop="16dp"        android:text="Price!"        android:textAllCaps="true"        android:textColor="@color/colorPrimary"        android:textSize="20sp" />



    <TextView        android:id="@+id/price_text_view"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/price"        android:paddingTop="16dp"        android:text="$ 0"        android:layout_marginLeft="8dp"        android:textColor="@android:color/black"        android:textSize="20sp" />




    <Button        android:id="@+id/button"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/price_text_view"        android:layout_weight="1"        android:onClick="submitOrder"        android:paddingTop="16dp"        android:text="ORDER"        android:textSize="20sp" />


</RelativeLayout>













Read More »

Thursday, February 14, 2019

LAYOUT WEIGHT - SPACING BTN VIEWS

https://developer.android.com/guide/topics/ui/layout/linear?utm_source=udacity&utm_medium=course&utm_campaign=android_basics

Layout Weight

LinearLayout also supports assigning a weight to individual children with the android:layout_weight attribute. This attribute assigns an "importance" value to a view in terms of how much space it should occupy on the screen. A larger weight value allows it to expand to fill any remaining space in the parent view. Child views can specify a weight value, and then any remaining space in the view group is assigned to children in the proportion of their declared weight. Default weight is zero.

Equal distribution

To create a linear layout in which each child uses the same amount of space on the screen, set the android:layout_height of each view to "0dp" (for a vertical layout) or the android:layout_width of each view to "0dp" (for a horizontal layout). Then set the android:layout_weight of each view to "1".

Unequal distribution

You can also create linear layouts where the child elements use different amounts of space on the screen:
  • If there are three text fields and two of them declare a weight of 1, while the other is given no weight, the third text field without weight doesn't grow. Instead, this third text field occupies only the area required by its content. The other two text fields, on the other hand, expand equally to fill the space remaining after all three fields are measured.
  • If there are three text fields and two of them declare a weight of 1, while the third field is then given a weight of 2 (instead of 0), then it's now declared more important than both the others, so it gets half the total remaining space, while the first two share the rest equally.
The following code snippet shows how layout weights might work in a "send message" activity. The To field, Subject line, and Send button each take up only the height they need. This configuration allows the message itself to take up the rest of the activity's height.
Read More »

LEARN CODING FROM UDACITY! BEGINNER LEVEL

https://classroom.udacity.com/courses/ud851
Read More »

XML DESIGNS

 image on center

android:scaleType = cenyterCrop"
Read More »

ANDROID: TOOLS FOR PICKING COLOR UI

https://material.io/design/color/#tools-for-picking-colors
Read More »

Saturday, May 14, 2016

ReFlex is The 2020 world's First Bendable Smartphone (Video)



Click HERE to Read the detailed post about Reflex, the smartphone of the future
Read More »

Sunday, March 13, 2016

Apple's Products: iPhone 7 Detailed Rumors Collection,Classification Conclusion And What's The Best Out Of It VIDEO

Read More »