This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package notepad; | |
| import javax.swing.*; | |
| import java.awt.*; | |
| import java.awt.event.*; | |
| import java.util.Scanner; | |
| import java.io.*; | |
| public class Notepad extends JFrame implements ActionListener { | |
| private TextArea textArea = new TextArea("", 0,0, TextArea.SCROLLBARS_VERTICAL_ONLY); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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."); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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."; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int numberOfSmoothiesTillPrize = 10; | |
| if (numberOfSmoothiesTillPrize > 9) { | |
| Log.v("SmoothieActivity", "Congratulations, you get a free smoothie!"); | |
| numberOfSmoothiesTillPrize = numberOfSmoothiesTillPrize - 10; | |
| } else { | |
| Log.v("SmoothieActivity", "No free smoothie this time."); | |
| } | |
| Log.v("SmoothieActivity", "You currently have " + numberOfSmoothiesTillPrize + " out of 10 smoothies needed for your next free smoothie."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.android.justjava; | |
| import android.content.Intent; | |
| import android.net.Uri; | |
| import android.os.Bundle; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.text.Editable; | |
| import android.view.View; | |
| import android.widget.CheckBox; | |
| import android.widget.EditText; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <resources> | |
| <!-- Base application theme. --> | |
| <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
| <!-- App branding color for the app bar --> | |
| <item name="colorPrimary">#009688</item> | |
| <!-- Darker variant for the status bar and contextual app bars --> | |
| <item name="colorPrimaryDark">#00796B</item> | |
| <!-- Theme UI controls like checkboxes and text fields --> | |
| <item name="colorAccent">#536DFE</item> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.android.justjava; | |
| import android.content.Intent; | |
| import android.net.Uri; | |
| import android.os.Bundle; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.text.Editable; | |
| import android.view.View; | |
| import android.widget.CheckBox; | |
| import android.widget.EditText; |
NewerOlder