Posts

Showing posts with the label Boil An Egg

Boil an egg app - step by step (step 3 – code)

Image
  After reviewing part 2 of the tutorial, it’s time for coding. let’s get started. In the main activity class we’ll have the following things to do: 1. set some private variables to be accessed from different places in the class. 2. bind some variables to views from the xml reviewed in part 2 3. set listeners for the different buttons on the screen 4. handle timer changing and displaying time remained   let’s elaborate on this : 1. initialize some variables in the main class, place those prior to the onCreate() method:     private Button btnSmallEgg,btnMediumEgg,btnLargeEgg;     private Button btnCookAnEggTimer,btnResetTimer;     private TextView btnSoftEgg,btnHardEgg;     private TextView tvTimer,tvTimerLabel;     private TextView tvChooseEggSize,tvChooseEggType,tvIntro ;         long minutes;     long seconds;     long maxTimer=600...

Boil an egg app - step by step (step 2 – Layouts)

      After doing part 1 , it’s time for coding – let’s write down the layouts used: layouts it’s easy to see that we have only a single layout, however – we have two: main_layout splash_layout the splash layout is pretty much a nifty way to show the user something that will make him a bit excited, it’s not mandatory, but it’s really nice. let’s review the splash screen and the main layout screen, the 2 files can be found at: https://www.dropbox.com/sh/cieiqif3lpzip2n/gC0jqfrBR6 Basically it’s a single LinearLayout containing an ImageView with the src directed to a png file in the drawables directory called splash. let’s review the main_layout layout: damn! seems like a complicated layout – no, it’s not – being a long xml doesn’t make it complicated, it just means it has a lot of views. lines 8-44 : header, intro text, and label for choosing an egg lines 46-150 : basically the layouts for choosing an egg size buttons, buttons for choosing egg type an...