Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mobile App Design - Lab 4 (Android)

7bf2baf0d8d5d7d96e6b67c5d567e3f9?s=47 Caren
October 16, 2018
79

Mobile App Design - Lab 4 (Android)

7bf2baf0d8d5d7d96e6b67c5d567e3f9?s=128

Caren

October 16, 2018
Tweet

Transcript

  1. Mobile App Design Week 4: Android Lab 2

  2. Review of Lab 1

  3. What are things we might need to know in order

    to build a popular Android app? Lab 1: Show data (text, images, videos) Create content and take users through different flows Save data Look nice!
  4. Flashcard App : Lab 1 Concepts covered:
 
 Android’s Activities

    Layouts Listeners GitHub
  5. Flashcard App : Lab 1 Activities - Represents a ‘screen’

    in an Android app. Activities are Java files where we handle user interactions
  6. Flashcard App : Lab 1 Activities - Represents a ‘screen’

    in an Android app. Activities are Java files where we handle user interactions Layouts - XML files composed of multiple views like Buttons, TextViews, ImageViews, and more
  7. Flashcard App : Lab 1 Activities - Represents a ‘screen’

    in an Android app. Activities are Java files where we handle user interactions Layouts - XML files composed of multiple views like Buttons, TextViews, ImageViews, and more Listeners - Let’s us ‘listen’ for certain user interactions and interact to them
  8. Common Problems Putting blocks of code in the wrong place


    protected void onCreate(Bundle savedInstanceState) { ... } findViewById(R.id.flashcard_question).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // do something } });
  9. Common Problems Putting blocks of code in the wrong place


    protected void onCreate(Bundle savedInstanceState) { ... } findViewById(R.id.flashcard_question).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // do something } }); protected void onCreate(Bundle savedInstanceState) { … findViewById(R.id.flashcard_question).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // do something } }); }
  10. Common Problems Putting blocks of code in the wrong place

    protected void onCreate(Bundle savedInstanceState) { … findViewById(R.id.flashcard_question).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // do something } }); } In order for our code to be called, we need to put it in the onCreate() method.
  11. Common Problems Putting blocks of code in the wrong place

    protected void onCreate(Bundle savedInstanceState) { … findViewById(R.id.flashcard_question).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // do something } }); } In order for our code to be called, we need to put it in the onCreate() method. onCreate() is called whenever a screen (or Activity) is first shown
  12. Common Problems Unable to call methods on certain views
 


    Why doesn’t the following work? findViewById(R.id.flashcard_question).setText("a question?");
  13. Common Problems Unable to call methods on certain views
 


    Why doesn’t the following work? findViewById(R.id.flashcard_question).setText("a question?”); Not all views have these specific methods, like setText(). Only views that contain text will have the method
  14. Common Problems Not all views have these specific methods, like

    setText(). Only views that contain text will have the method
 ((TextView) findViewById(R.id.flashcard_question)).setText("a question?");

  15. Common Problems Not all views have these specific methods, like

    setText(). Only views that contain text will have the method
 ((TextView) findViewById(R.id.flashcard_question)).setText("a question?");
 OR TextView flashcardQuestion; @Override protected void onCreate(Bundle savedInstanceState) { ... flashcardQuestion = findViewById(R.id.flashcard_question); flashcardQuestion.setText("a question?”); }
  16. Common Problems Importing classes You can auto import all classes!!

    Check out the ‘Auto Import’ section in ‘Android Studio Starter Guide’, linked in course portal
  17. Common Problems Importing classes

  18. What are things we might need to know in order

    to build a popular Android app? Show data (text, images, videos) Lab 2: Create content and take users through different flows Save data Look nice!
  19. Flashcard App : Lab 2 Concepts covered:
 
 Android’s Intents

    Resources and Drawables EditText Views
  20. Quick Concepts Introduction

  21. Android Intents An Intent is Android's way of saying it

    has an "intention" to perform an action.
  22. Android Intents An Intent is Android's way of saying it

    has an "intention" to perform an action. Android uses these Intent objects to specify what it wants to happen (ie : start a new Activity).
  23. Android Intents ActivityA Intent intent = new Intent(ActivityA.this, ActivityB.class); startActivity(intent);

    ActivityB
  24. Android Intents An Intent is Android's way of saying it

    has an "intention" to perform an action. Android uses these Intent objects to specify what it wants to happen (ie : start a new Activity). When an Intent is used, data can also be attached to the Intent so that more information can be given to the 'receiver' of the intent.
  25. Android Intents ActivityA Intent intent = new Intent(ActivityA.this, ActivityB.class); intent.putExtra(“key",

    “some info to send”); startActivity(intent); ActivityB protected void onCreate(Bundle savedInstanceState) { … String data = getIntent().getStringExtra(“key"); // data = “some info to send”
  26. Resources and Drawables Resources in Android can be used to

    define a wide range of things (colors, images, layouts, strings).
  27. Resources and Drawables Resources in Android can be used to

    define a wide range of things (colors, images, layouts, strings). Drawables are a specific type of resource that can be “drawn” onto a screen
  28. Resources and Drawables Resources in Android can be used to

    define a wide range of things (colors, images, layouts, strings). Drawables are a specific type of resource that can be “drawn” onto a screen They can be Bitmap files (created from PNG, JPG or Vector based files) or XML files that we can use as icons or backgrounds for views.
  29. EditText Views EditText is a specific type of view that

    allows user input.
  30. EditText Views EditText is a specific type of view that

    allows user input. 
 It can be customized to things such as :
 - how many lines the user can input
 - the text that is shown when there is no input
  31. Working on Labs Questions?
 1. Ask for help from group

    members
 2. Ask for TA help
  32. Working on Labs Questions?
 1. Ask for help from group

    members
 2. Ask for TA help Only the Required Features need to be finished and submitted. For submission, you should submit a GIF that shows all the features you implemented