Skip to content

Instantly share code, notes, and snippets.

View Mohanad0's full-sized avatar

Mohanad Naji Salim Mohanad0

View GitHub Profile
@Mohanad0
Mohanad0 / Method 1
Created May 28, 2018 23:58 — forked from udacityandroid/Method 1
Android Development for Beginners : Define a Method
/**
* Get the email account name.
*
* @return the name of the account.
*/
private String getAccountName() {
return "android@gmail.com";
return "droid@gmail.com";
}
@Mohanad0
Mohanad0 / TextView.java
Created May 29, 2018 00:09 — 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;
@Mohanad0
Mohanad0 / ImageView.java
Created May 29, 2018 00:09 — 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;
@Mohanad0
Mohanad0 / MainActivity.java
Created May 29, 2018 16:54 — forked from udacityandroid/MainActivity.java
Android for Beginners : Cookies Solution Code
package com.example.android.cookies;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Mohanad0
Mohanad0 / activity_main.xml
Created May 29, 2018 23:39 — forked from udacityandroid/activity_main.xml
Android for Beginners : Add the Chocolate Topping Checkbox Solution XML
<ScrollView 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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@Mohanad0
Mohanad0 / Code snippet from MainActivity.java
Created May 30, 2018 18:22 — forked from udacityandroid/Code snippet from MainActivity.java
Android for Beginners : Negative Number of Cups of Coffee Extra Challenge Solution
/**
* This method is called when the plus button is clicked.
*/
public void increment(View view) {
if (quantity == 100) {
// Show an error message as a toast
Toast.makeText(this, "You cannot have more than 100 coffees", Toast.LENGTH_SHORT).show();
// Exit this method early because there's nothing left to do
return;
}
@Mohanad0
Mohanad0 / Option A
Created June 3, 2018 22:24 — 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;
}
@Mohanad0
Mohanad0 / Code snippet in WeatherActivity.java
Created June 7, 2018 15:15 — forked from udacityandroid/Code snippet in WeatherActivity.java
Android for Beginners : If/Else Weather Quiz
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.");
}
@Mohanad0
Mohanad0 / Code snippet in WeatherActivity.java
Created June 7, 2018 15:19 — forked from udacityandroid/Code snippet in WeatherActivity.java
Android for Beginners : If/Else Weather Sample Quiz
boolean isRaining = true;
if (isRaining) {
Log.v("WeatherActivity", "It's raining, better bring an umbrella.");
} else {
Log.v("WeatherActivity", "It's unlikely to rain.");
}
Log.v("WeatherActivity", "Thank you for using the WhetherWeather App.");
@Mohanad0
Mohanad0 / Code snippet in InboxActivity.java
Created June 7, 2018 15:32 — forked from udacityandroid/Code snippet in InboxActivity.java
Android for Beginners : If/Else Email Quiz
int numberOfEmailsInInbox = 0;
int numberOfDraftEmails = 2;
String emailMessage = "You have " + numberOfEmailsInInbox + " emails. ";
String draftMessage = "You have " + numberOfDraftEmails + " email drafts.";
if (numberOfEmailsInInbox == 0) {
emailMessage = "You have no new messages. ";
}
if (numberOfDraftEmails == 0) {
draftMessage = "You have no new drafts.";