Advanced Android 01.1:Fragments✍

0

Google Codelabs

목록 보기
12/14
post-thumbnail

Advanced Android 01.1:Fragments

이 포스팅은 아래 구글 코드랩을 개인 학습용으로 정리한 글입니다.

1. Welcome

  • Fragment:
    • self-contained component with its own user interface (UI) and lifecycle
    • can be reused in different parts of an app's UI
  • A Fragment can also be used without a UI
    -> in order to retain values across configuration changes

2. App overview

  • In the first task, you add the Fragment statically to the Activity layout
    -> it is displayed for the entire duration of the Activity lifecycle

  • The user can interact with the radio buttons in the Fragment
    -> choose either "Yes" or "No"
    -> If the user chooses "Yes," the text in the Fragment changes to "Article: Like."
    -> If the user chooses "No," the text in the Fragment changes to "Article: Thanks."

  • In the second task, you add the Fragment dynamically
    -> your code adds, replaces, and removes the Fragment while the Activity is running

  • the user can tap the Open button
    -> to show the Fragment at the top of the screen.

  • The user can then interact with the UI elements in the Fragment.

  • The user taps Close
    -> to close the Fragment.

3. Task 1. Include a Fragment for the entire Activity lifecycle

1.1 Open the starter app project

✍...

📌참고자료

  • In the instructions below, substitute your actual project names
    -> ExistingProject and NewProject.
  1. Copy the project
  • On your computer's file system (not in Android Studio)
    -> make a copy of the ExistingProject directory.
  • Rename the copied directory to NewProject.
  1. Rename and refactor the project components
  • Start Android Studio
    -> Open an existing Android Studio project
    -> select NewProject directory
  • Select Build > Clean Project to remove the auto-generated files
  • See your files in the Project: Android view.
    -> Right-click app > java > com.example.android.existingproject
    -> select Refactor > Rename
  • A Warning dialog is displayed
    -> select Rename package.
    -> Select Search in comments and strings and Search for text occurrences.
    -> Click Refactor.
  • The Find: Refactoring Preview pane appears
    -> Click Do Refactor.
  • Change the app_name string value to "New Project" in the strings.xml file
profile
Be able to be vulnerable, in search of truth

0개의 댓글