Skip to content

Instantly share code, notes, and snippets.

@abdahma01
abdahma01 / strings.xml
Created Mar 30, 2018 — forked from udacityandroid/strings.xml
Android for Beginners : Spanish Localization Solution. This would be saved in the res/values-es/strings.xml file.
View strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Title for the application. [CHAR LIMIT=12] -->
<string name="app_name">Sólo Java</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">Nombre</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">Ingredientes</string>
View Code snippet in WeatherActivity.java
boolean isRaining = false;
Log.v("WeatherActivity", "Thank you for using the WhetherWeather App.");
if (isRaining) {
Log.v("WeatherActivity", "It's raining, better bring an umbrella.");
} else {
Log.v("WeatherActivity", "It's unlikely to rain.");
}
@abdahma01
abdahma01 / MainActivity.java
Created Mar 30, 2018 — forked from udacityandroid/MainActivity.java
Android for Beginners : Add the Chocolate Topping Checkbox Solution Java
View MainActivity.java
package com.example.android.justjava;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;
/**
* This app displays an order form to order coffee.
View New method in MainActivity.java
/**
* 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));
}
View Just Java Localization (Arabic Translation)
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;
@abdahma01
abdahma01 / ImageView.java
Created Feb 17, 2018 — forked from udacityandroid/ImageView.java
Android for Beginners : Simplified ImageView class
View ImageView.java
/**
* 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;
@abdahma01
abdahma01 / TextView.java
Created Feb 17, 2018 — forked from udacityandroid/TextView.java
Android for Beginners : Simplified TextView class
View TextView.java
/**
* Displays text to the user.
*/
public class TextView extends View {
// String value
private String mText;
// Text color of the text
private int mTextColor;
View Calculate price method
/**
* 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 / Method 1
Created Feb 15, 2018 — forked from udacityandroid/Method 1
Android Development for Beginners : Define a Method
View Method 1
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 / Option A
Created Feb 15, 2018 — forked from udacityandroid/Option A
Android Development for Beginners : Calculate the Price Method
View Option A
/**
* 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;
}
You can’t perform that action at this time.