Monday, August 1, 2016

CHP2_Interactive App


Goals
  • make activity and layout like bros
  • let your app do something to  response  the user

Project One _ Adviser
  • GUI components for layout
    • spinner
    • button
    • textfield
  • strings.xml
  • activity
  • java class

============================================================================================================================================

Steps

  1. build the project => basic layout and activity
  2. refresh layout => put on all the GUI components you'd like to have
  3. connect layout to the activity => appearance and the brain
  4. java class => the logic of the  code  


============================================================================================================================================

  • Design Editor
    • Palette
      • GUI components toolbox
        • Widgets
  • Text Editor
    • <TextView
      • ID

Both Design and Text Editor were extends by Android View Class
  • android : id
  • android :text
  • android : layout_width
  • android : layout_height

============================================================================================================================================
  • Spinner => dropdown menu
    • spinner add values => res (noncode assets) ; eg , graph , string
    • strings.xml
      • single string
      • string array
    • make spinner reference to string -array
  • GUI elements => eg . button. textfield . spinner has similar properties , coz they are same "View class"
  • write dead into text property or using strings.xml  handle static text 
    • make you easily transfer to different languages. 
    • uniform one place for modify your text
    • app/src/main/res/values/strings.xml

============================================================================================================================================


Quick Recap

  • All of the GUI components are Android View class's subclass.
  • <string-array name ="array">  =>strings.xml
      • <item>string1</item>
      • ...
    • </string-array>
  • "@array/array_name" => Layout
  • android : onClick = "clickMethod" => Layout
  • public void clickMethod(View view) { }  =>Activity
  • R.java ,for reference
  • findViewById() get view reference
  • setText()
  • getSelectedItem()
  • File -> New ... -> Java Class

No comments:

Post a Comment