Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Java
  • Android
  • Kotlin
  • Flutter
  • Dart
  • Android with Java
  • Android Studio
  • Android Projects
  • Android Interview Questions
Open In App
Next Article:
How to Build a Palindrome Checker App in Android Studio?
Next article icon

How to Build a Palindrome Checker App in Android Studio?

Last Updated : 03 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will be building a Palindrome Checker android app in Android Studio using Java/Kotlin and XML. The app will check whether the entered word is Palindrome or not, if the entered word is a Palindrome then a toast will be displayed having the message "Yes, it's a palindrome" otherwise Toast's message will be "No, it's not a palindrome".

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.

Step 2: Working with the activity_main.xml file

This file contains an EditText view which takes the input from the user, and a Button view, on clicking which the app will check whether the entered word is Palindrome or not. Below is the code for the activity_main.xml file.

activity_main.xml:

XML
<?xml version="1.0" encoding="utf-8"?> <LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:gravity="center"     android:orientation="vertical"     tools:context=".MainActivity">      <EditText         android:id="@+id/editText"         style="@style/Widget.Material3.Button.OutlinedButton"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:hint="Enter a word"         android:textColor="@color/black"         android:textSize="24sp" />      <Button         android:id="@+id/button"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_marginTop="32dp"         android:text="Check"         android:textSize="25sp" />  </LinearLayout> 


Step 3: Working with the MainActivity file

Inside the class MainActivity, we will create a function "isPalindrome()" which will take a string value as a parameter and returns a Boolean value, it will return true if the string is Palindrome and if the string is not a Palindrome it will return false. Now, inside the onCreate function, we will call a setOnClickListener method on button, inside it, we pass the text value of editText to "isPalindrome()" function as an argument, if the returned value is true, we will display a Toast having message "Yes, it's a palindrome" and if the returned value is False, we will display a Toast having the message "No, it's not a palindrome".

Below is the code for the MainActivity file.

MainActivity.java
package org.geeksforgeeks.demo;  import android.os.Bundle; import android.widget.Button; import android.widget.EditText; import android.widget.Toast;  import androidx.appcompat.app.AppCompatActivity;  public class MainActivity extends AppCompatActivity {      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          EditText editText = findViewById(R.id.editText);         Button button = findViewById(R.id.button);          button.setOnClickListener(v -> {             String text = editText.getText().toString();             if (isPalindrome(text)) {                 Toast.makeText(MainActivity.this, "Yes, it's a palindrome", Toast.LENGTH_SHORT).show();             } else {                 Toast.makeText(MainActivity.this, "No, it's not a palindrome", Toast.LENGTH_SHORT).show();             }         });     }      private boolean isPalindrome(String text) {         String reverseString = new StringBuilder(text).reverse().toString();         return text.equalsIgnoreCase(reverseString);     } } 
MainActivity.kt
package org.geeksforgeeks.demo  import android.os.Bundle import android.widget.Button import android.widget.EditText import android.widget.Toast import androidx.appcompat.app.AppCompatActivity  class MainActivity : AppCompatActivity() {      override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)         setContentView(R.layout.activity_main)          val editText: EditText = findViewById(R.id.editText)         val button: Button = findViewById(R.id.button)          button.setOnClickListener {             val text = editText.text.toString()             if (isPalindrome(text)) {                 Toast.makeText(this, "Yes, it's a palindrome", Toast.LENGTH_SHORT).show()             } else {                 Toast.makeText(this, "No, it's not a palindrome", Toast.LENGTH_SHORT).show()             }         }     }      private fun isPalindrome(text: String): Boolean {         val reverseString = text.reversed()         return text.equals(reverseString, ignoreCase = true)     } } 

Output:


Next Article
How to Build a Palindrome Checker App in Android Studio?

N

nirajgusain5
Improve
Article Tags :
  • Kotlin
  • Android
  • Kotlin Android
  • Android-Studio
  • Android Projects
  • Java-Android

Similar Reads

    How to Build a Prime Number Checker Android App in Android Studio?
    A prime number is a natural number greater than 1, which is only divisible by 1 and itself. First few prime numbers are : 2 3 5 7 11 13 17 19 23 ….. . In this article, we will be building a Prime Number Checker android app in Android Studio using Kotlin and XML. The app will check whether the entere
    3 min read
    How to build a simple Calculator app using Android Studio?
    Create a simple calculator which can perform basic arithmetic operations like addition, subtraction, multiplication, or division depending upon the user input. A sample video 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
    6 min read
    How to Build a Sudoku Solver Android App?
    In this article, we are going to make a sudoku solver Android app in Kotlin and xml. The main focus of the app will be on the sudoku-solving algorithm so the the design part has been hardcoded. A sample video is given below to get an idea about what we are going to do in this article. Step by Step I
    12 min read
    How to Build a Number Shapes Android App in Android Studio?
    Android is a vast field to learn and explore and to make this learning journey more interesting and productive we should keep trying new problems with new logic. So, today we are going to develop an application in android studio which tells us about Numbers that have shapes. We will be covering two
    4 min read
    How to Build Fibonacci Perfect Square App using Android Studio?
    Fibonacci Perfect Square App built using Android Studio is used to check whether the number entered by the user is a Fibonacci number or Perfect Square number or both. The output is displayed on SnackBar. A sample video is given below to get an idea about what we are going to do in this article. Not
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences