跳到主要內容

【Android Development for Beginners】Lesson 2A : Make the Quantity Picker Work

This Notes is according to the udacity free course :

Android Development for Beginners

Lesson 2A : Make the Quantity Picker Work

In Last Class we still cannot fix the problem to increase the coffee quantity automatic.
After the practice, now we can face the problem.



In this class, the most important concept is Global variable.
Keep it in your mind, it is the key word to fix the problem.

We use one pic to explain what the problem we face on.


We can see that "int quantity = 2" is exist in different code sequence with a complete brackets, they execute the action individually.

And Now, what we have to do is to level up the code " int quantity = 2" to a public class.


Tips : When you create a global variable the words will turn into purple. If it is a local variable, it will shows up in black.


H.W.

The Code is create a GLOBAL VARIABLE and the "int quantity = 2" is under " public class MainActivity.

After the procedure, you can update the coffee quantity immediately.
Press Run and check out your application.

留言

這個網誌中的熱門文章

【Android Development for Beginners】 Lesson 2A : Create a New Project , Plan How to Build the Layout, Build Layout

This Notes is according to the udacity free course : Android Development for Beginners Lesson 2A : Create a New Project Plan How to Build the Layout Build layout Follow the instruction below to build up a new app called "Just Java" use empty activity .

【 Android Development for Beginners】 Lesson 3A : Object Oriented Programming - 4

(I think Lesson 3A is the most important but also the most difficult part for beginner so far ) This Notes is according to the udacity free course : Android Development for Beginners Lesson 3A : Object Oriented Programming Call Method on an objects If We want to call a method on an object object variable name . method name ( input argument ); ex: titleTextView.setText("News"); You need to make sure you put a right object so you can call the method

【Android Development for Beginners】Lesson 2B : String Data Type, Combining Strings Together, and Integer Variables

This Notes is according to the udacity free course : Android Development for Beginners Lesson 2B :  String Data Type,  Combining Strings Together and Integer Variables Finally We cross the river and change the layouts successfully. But We can do it better by letting the price change automatically but not change after the we click the "order" button. So this is what we want to do in this class.