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

Mobile App Design - Lab 4 (Android)

Caren
October 16, 2018
91

Mobile App Design - Lab 4 (Android)

Caren

October 16, 2018
Tweet

Transcript

  1. 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!
  2. Flashcard App : Lab 1 Activities - Represents a ‘screen’

    in an Android app. Activities are Java files where we handle user interactions
  3. 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
  4. 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
  5. 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 } });
  6. 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 } }); }
  7. 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.
  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 } }); } 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
  9. Common Problems Unable to call methods on certain views
 


    Why doesn’t the following work? findViewById(R.id.flashcard_question).setText("a question?");
  10. 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
  11. 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?");

  12. 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?”); }
  13. 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
  14. 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!
  15. Android Intents An Intent is Android's way of saying it

    has an "intention" to perform an action.
  16. 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).
  17. 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.
  18. 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”
  19. Resources and Drawables Resources in Android can be used to

    define a wide range of things (colors, images, layouts, strings).
  20. 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
  21. 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.
  22. 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
  23. 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