Last active
January 27, 2017 02:58
-
-
Save dashengz/cf90fb120b1c8e954889579e05632e43 to your computer and use it in GitHub Desktop.
Starting code for the Coffee Ordering App's MainActivity.java
This file contains 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 your.package.name; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.TextView; | |
public class MainActivity extends AppCompatActivity { | |
// Global variable for quantity | |
... | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
} | |
/** | |
* This method is called when the plus button is clicked. | |
*/ | |
public void increment(View view) { | |
// Your code here | |
... | |
} | |
/** | |
* This method is called when the minus button is clicked. | |
*/ | |
public void decrement(View view) { | |
// Your code here | |
... | |
} | |
/** | |
* This method is called when the order button is clicked. | |
* | |
* @param view The View whose onclick attribute has the value "submitOrder" | |
*/ | |
public void submitOrder(View view) { | |
// Your code here | |
... | |
} | |
/** | |
* Display the given number in quantity_text_view. | |
* | |
* @param number The number to be displayed in quantity_text_view | |
*/ | |
private void displayNumber(int number) { | |
TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view); | |
quantityTextView.setText(String.valueOf(number)); | |
} | |
/** | |
* Display the given text in price_text_view. | |
* | |
* @param message The message to be displayed in price_text_view | |
*/ | |
private void displayMessage(String message) { | |
TextView priceTextView = (TextView) findViewById(R.id.price_text_view); | |
priceTextView.setText(message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment