Skip to main content

Command Palette

Search for a command to run...

Activity: Practice Android Java Activity Components

Updated
4 min read

You will create 10 different Android activities, each performing specific functions as described in the components. Follow the instructions for each activity, and then you will push the code to GitHub and document it on Hashnode.

1. DisplayHelloWorldActivity

  • Goal: Display the text "Hello World" on the screen using a variable from the Kotlin/Java file.

  • Instructions:

    • Create an activity named DisplayHelloWorldActivity.

    • Add a TextView in the layout.

    • In the activity, set the text of the TextView to "Hello World".

2. ShowHelloButtonActivity

  • Goal: Create a button, and when the user clicks the button, display "Hello World".

  • Instructions:

    • Create an activity named ShowHelloButtonActivity.

    • Add a Button and a TextView in the layout.

    • Set the TextView to display "Hello World" when the button is clicked.

3. DisplayNameActivity

  • Goal: User inputs their name, and when the button is clicked, their name is displayed on the screen.

  • Instructions:

    • Create an activity named DisplayNameActivity.

    • Add an EditText, Button, and TextView in the layout.

    • When the button is clicked, show the user's inputted name in the TextView.

4. CounterActivity

  • Goal: Create a counter that increases by 1 when the user clicks a button.

  • Instructions:

    • Create an activity named CounterActivity.

    • Add a Button and a TextView in the layout.

    • Implement logic to increment the counter every time the button is clicked and display the value in the TextView.

5. SimpleFormActivity

  • Goal: Create a form with text inputs and a submit button, display the submitted input data.

  • Instructions:

    • Create an activity named SimpleFormActivity.

    • Add EditText fields for the form inputs, a Button to submit, and a TextView to display the input data.

6. UserAgeActivity

  • Goal: Input the user’s birth year, and when the button is clicked, display their age.

  • Instructions:

    • Create an activity named UserAgeActivity.

    • Add an EditText to input the birth year, a Button, and a TextView.

    • Calculate and display the user's age when the button is clicked.

7. CalculatorActivity

  • Goal: Create a simple calculator with add, subtract, multiply, and divide functionalities.

  • Instructions:

    • Create an activity named CalculatorActivity.

    • Add two EditText fields to input numbers, four Buttons for the operations, and a TextView to display the result.

    • Implement the basic arithmetic functions in the activity.

8. EvenOddCheckerActivity

  • Goal: Input a number and check if it is even or odd.

  • Instructions:

    • Create an activity named EvenOddCheckerActivity.

    • Add an EditText to input a number, a Button, and a TextView.

    • Implement logic to check if the number is even or odd and display the result.

9. ShowDateActivity

  • Goal: Create a button that shows the current date and time when clicked.

  • Instructions:

    • Create an activity named ShowDateActivity.

    • Add a Button and a TextView in the layout.

    • Implement the logic to show the current date and time when the button is clicked.

10. PalindromeCheckerActivity

  • Goal: Input a word and check if it's a palindrome.

  • Instructions:

    • Create an activity named PalindromeCheckerActivity.

    • Add an EditText to input a word, a Button, and a TextView.

    • Implement logic to check if the word is a palindrome and display the result.


Project Setup and Commit Instructions

  1. Create a New Android Project:

    • Create a new Android project using Android Studio.

    • Add 10 activities as per the instructions above.

  2. Implement Each Activity:

    • For each activity, create a corresponding XML layout and add the necessary UI elements (e.g., Button, TextView, EditText).

    • Implement the functionality in the Kotlin/Java code based on the component descriptions.

  3. Commit Your Changes to GitHub:

    • For each activity, create a meaningful commit.

    • Example commit message: #1DisplayHelloWorldActivity

    • Ensure there are 10 commits in total, each corresponding to a different activity.

  4. Push the Entire Project to GitHub:

    • Once all activities are created, push the project to a GitHub repository.
  5. Don't use AI to generate your code. Instead, focus on mastering and understanding on Android Java


Documentation on Hashnode or Medium.com

  1. Write a Blog Post:

    • Document the project by explaining the process of creating the 10 Android activities (add output in the screenshot).

    • Include brief descriptions of each activity and explain how they work.

    • Provide code snippets where necessary.

    • Add the link to your GitHub repository in the post so others can access the code.

  2. Share on the Portal:

    • Once post is complete, share the link on the appropriate platform.

More from this blog

T

Thirdy Gayares

99 posts

Software Engineer | Mobile Developer | Data Scientist