Skip to content

Instantly share code, notes, and snippets.

View araby123's full-sized avatar
🏠
Working from home

Eng. Mohammed Araby araby123

🏠
Working from home
View GitHub Profile
@udacityandroid
udacityandroid / Code snippet in InboxActivity.java
Last active February 6, 2023 13:53
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.";
@udacityandroid
udacityandroid / Calculate price method
Created June 9, 2015 23:49
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;
}
/**
* 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);
}
anonymous
anonymous / Option A
Created April 25, 2015 02:23
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">
anonymous
anonymous / activity_main.xml
Created April 8, 2015 22:18
RelativeLayout XML for Udacity quiz question
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">
<TextView
android:text="I’m in this corner"
android:layout_height="wrap_content"
android:layout_width="wrap_content"