Skip to content

Instantly share code, notes, and snippets.

package com.example.android.justjava;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.TextView;
import java.text.NumberFormat;
/**
@abdahma01
abdahma01 / Option A
Created February 12, 2018 11:59 — forked from anonymous/Option A
3 options for the layout of an activity for a quiz question
<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"
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=".MainActivity">
/**
* 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);
}
@abdahma01
abdahma01 / activity_main.xml
Created February 14, 2018 01:13 — forked from udacityandroid/activity_main.xml
Android Development for Beginners : Court Counter - The Stages
<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">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
@abdahma01
abdahma01 / Option A
Created February 15, 2018 20:51 — forked from udacityandroid/Option A
Android Development for Beginners : Calculate the Price Method
/**
* Calculates the price of the order based on the current quantity.
*
* @return the price
*/
private int calculate price(int quantity {
int price = quantity * 5;
return price;
}
@abdahma01
abdahma01 / Method 1
Created February 15, 2018 21:36 — forked from udacityandroid/Method 1
Android Development for Beginners : Define a Method
private String createCalendarEventReminder(String eventName, String location, int minutesAway) {
String reminder = "You have an upcoming event in " + minutesAway + " minutes.";
reminder = reminder + " It is " + eventName + " held at " + location + ".";
return reminder;
}
@abdahma01
abdahma01 / Calculate price method
Created February 15, 2018 22:29 — forked from udacityandroid/Calculate price method
Add to MainActivity.java
/**
* Calculates the price of the order.
*
* @param quantity is the number of cups of coffee ordered
*/
private void calculatePrice(int quantity) {
int price = quantity * 5;
}
@abdahma01
abdahma01 / TextView.java
Created February 17, 2018 19:17 — forked from udacityandroid/TextView.java
Android for Beginners : Simplified TextView class
/**
* Displays text to the user.
*/
public class TextView extends View {
// String value
private String mText;
// Text color of the text
private int mTextColor;
@abdahma01
abdahma01 / ImageView.java
Created February 17, 2018 19:18 — forked from udacityandroid/ImageView.java
Android for Beginners : Simplified ImageView class
/**
* Displays an image, such as an icon.
*/
public class ImageView extends View {
// Resource ID for the source image that should be displayed in the ImageView.
private int mImageId;
// Context of the app
private Context mContext;
package com.example.android.coffeeupdated;
import android.content.Intent;
import android.icu.text.NumberFormat;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;