![]() |
VOOZH | about |
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.
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.
Go to app > res > values > colors.xml and add the following color attributes.
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
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.
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.