VOOZH about

URL: https://www.geeksforgeeks.org/android/how-to-create-a-voting-application-in-android/

⇱ How to Create a Voting Application in Android? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Create a Voting Application in Android?

Last Updated : 23 Jul, 2025

In general, voting means comparing two or more entities on the basis of certain conditions. In this article, we will create a simple voting application that uses two different programming languages namely Java and Python, and ask the user to vote for their preferred language. A sample GIF is given below to get an idea about what we are going to do in this article.

Note that we are going to implement this project using Java language.

Step-by-Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language. Before moving further let's add some color attributes in order to enhance the app bar.

👁 Directory_Structure



Go to app > res > values > colors.xml and add the following color attributes. 


Step 2: Adding Resources

In this step, we will add image resources to our application. These images are placed in the drawable folder(app > res > drawable). You can use any images in place of these.

Refer to this article: How to Add Image to Drawable Folder in Android Studio


Step 3: Working with the activity_main.xml file

In this step, we will create the layout for our voting application to compare votes for two different objects. For this, go to app > res > layout > activity_main.xml and add the following code snippet.


Step 4: Working with the MainActivity.java file

In MainActivity.java, we will initialize our Text and Button views and add onClickListener() to the button which is used to update the values in the TextView. Comments are added inside the code to understand the code in more detail.

Output:

Comment
Article Tags:

Explore