Friday, October 10, 2014

Android Tutorial Chapter 5 + Chapter 6

The book has been pretty helpful so far and I think xml is pretty simple considering it's just tag notation(the layouts can be a bit confusing though) and Finn's code is starting to make more sense.
Chapter 5
  • Intents change the activity so a main menu button could change to a different menu, or activity like a settings menu
  • Views are just UI elements like seekbars or buttons
  • Resources are elements imported into the project like pictures, text etc
  • To specify an xml file you write the name out with R.layout.name because there is a file that connects the xml and java called an R file
    • ImageView imageView = (ImageView) findViewById(R.id.myimageview);
      imageView.setImageResource(R.drawable.myimage);
  • Strings.xml just contains all the strings the app uses 
  • I also made a hello world app which was pretty easy because it was just xml
Chapter 6
  • This chapter focused on organizing the resource folder which generally looks like this                                                                                                      
    • MyProject/
          src/
      MyActivity.java
          res/
              drawable/
                  icon.png
          layout/
                  activity_main.xml
                  info.xml
           values/
                  strings.xml  
  • There are also many other sub directories which are supported which can be seen below along with what they do
    • anim/: XML files that define property animations. They are saved in res/anim/ folder and accessed from the R.anim class. 
    • color/: XML files that define a state list of colors. They are saved in res/color/ and accessed from the R.color class.
    • drawable/: Image files like .png, .jpg, .gif or XML files that are compiled into bitmaps, state lists, shapes, animation drawables. They are saved in res/drawable/ and accessed from the R.drawable class.
    • layout/: XML files that define a user interface layout. They are saved in res/layout/ and accessed from the R.layout class. 
    • menu/: XML files that define application menus, such as an Options Menu, Context Menu, or Sub Menu. They are saved in res/menu/ and accessed from the R.menu class.
    • raw/: Arbitrary files to save in their raw form. You need to
      callResources.openRawResource() with the resource ID, which is R.raw.filename to open such raw files.
    • values/: XML files that contain simple values, such as strings, integers, and colors. For example, here are some filename conventions for resources you can create in this directory: arrays.xml for resource arrays, and accessed from the R.array class. integers.xml for resource integers, and accessed from the R.integerclass. bools.xml for resource boolean, and accessed from the R.bool class. colors.xml for color values, and accessed from the R.color class. dimens.xml for dimension values, and accessed from the R.dimen class. strings.xml for string values, and accessed from the R.string class. styles.xml for styles, and accessed from the R.style class.
    • xml/: Arbitrary XML files that can be read at runtime by calling Resources.getXML(). You
      can save various configuration files here which will be used at run time.
  • Also I mentioned some of this before but there are alternative resources which are resources that are used under certain conditions so I said before in a different post that there are different drawable folders like drawable-hdpi, drawable-xhdpi, etc where different pictures would be used on different devices due to their resolution. The book also stated that another possible alternative resource would be in the layout folder called layout-ar which would be used to change the language of the UI to arabic when needed.

2 comments:

  1. Again, please provide a link to the tutorial you are using in each post that references it.

    As you can see, even the directory structure of applications like these gets pretty complicated, especially by the time you add in the "other sub directories". If you spend enough time with Android development, the basic directory structure you are describing here will become a very familiar place, and you will then be able to wonder around it without getting loss. That takes time and experience, however, so I hope the tutorial you are using will lead you step-by-step toward this familiarity.

    ReplyDelete
  2. Goals for next week:

    1. Write a plan tomorrow that includes your goals for the week, specifically referencing the tutorial and providing a link to it.
    2. Provide journal entries on Wednesday and Thursday that describe the progress you make toward meeting your plan.
    3. Provide a reflection on Friday that self evaluates the progress you made during the week.

    ReplyDelete