Tag Archives: setOnClickListener

Setting button actions programatically in Java, Python, JavaScript, SWIFT and Kotlin

By | January 9, 2024

Button action calls for an action when user tap on a button. This may be for making a service call, for doing some calculation or simply just to dismiss a view. Here are the different ways of setting button action in different languages. Java Python (TKinter) JavaScript: Swift Kotlin These examples demonstrate how to set… Read More »

DataBinding in Android using Observable Collections

By | January 30, 2017

As I shown in the previous post where we used BaseObservable and ObservableField to update UI when binding object is changed, this post will show you another simple way to achieve this. Do Check my previous posts for better understanding of DataBinding and methods used in DataBinding. http://www.coderzheaven.com/2017/01/15/simple-databinding-in-android-example/ http://www.coderzheaven.com/2017/01/20/data-binding-in-android-using-observables/ http://www.coderzheaven.com/2017/01/25/data-binding-in-android-using-observablefield-to-update-ui-automatically/ Here is another way to… Read More »

SnackBar and Floating Button Demo in Android

By | February 22, 2016

Snackbar is a UI element used for user feedback, just like a Toast except they provide action to interact with. Snackbar will be displayed at the bottom of the screen and can be swiped off in order to dismiss them. Floating Button sits on the top of your layout and provides a way for a… Read More »

How to create animation by default in a GridLayout in Android?

By | June 2, 2013

This example shows you how to create animation using the default XML tag in a gridview. This application demonstrates how to use the animateLayoutChanges tag in XML to automate transition animations as items are removed from or added to a container. Click on the download link to get the source code. Let’s have a look.… Read More »

How to draw Arcs in Android using canvas?

By | January 10, 2013

This is a simple example showing how to draw Arcs in android, You can use this to create piecharts or someother similar thing you want. Here we have 3 classes. 1. GraphicsActivity.java 2. MainActivity.java 3. PictureLayout.java GraphicsActivity.java PictureLayout.java MainActivity.java Download the complete source code from here.

How to copy a file to another saved in SDCARD in Android?

By | December 30, 2012

Hello all… This tutorial explains how to copy a file contents to another in Android. The file to copy is saved in SDCARD, however you can change the path to save it in your application sandbox. if you want to save it in your sandbox, change the path to /data/data/your_packagename/your_file.extension Now we will see the… Read More »

Passing data between Intents or classes in ANDROID?

By | March 29, 2012

Many of our application reqiures sending data from one intent to another. This is done by putting data into one intent using putExtras() and getting it in the other intent using the getExtras() which matches the string value. However you can pass string, boolean, integer etc between intents. For passing data between intents you need… Read More »

Send Data when Clicking on a Notification in Android?

By | March 10, 2012

Hello everyone… I have shown in my previous tutorials on how to create notification in android and cancel it. This is the post showing this . Now today I am going to show how to send data when you click on the notification message. Here I am creating two activities. One the main activity that… Read More »

How to use global variables in android? -Part 2

By | February 20, 2012

Hello all…. In a previous post I showed a method to share global variables across your android application. Those were done using a static class. Now today I will show you another way of sharing global variables across the application Check these posts for sharing data across the application. 1. http://coderzheaven.com/2011/05/global-variables-in-android/ 2. http://coderzheaven.com/2011/05/global-variables-in-android%e2%80%a6/ 3. http://coderzheaven.com/2011/03/passing-data-between-intents-in-android/… Read More »

How to change the default transition between activities?

By | October 26, 2011

In android the default transition between activities is to slide from left to right. But with custom animations we can change that. First create a folder inside the res/drawable folder called “anim”. Then create a file named “fade.xml” and copy this code into it. create another file named “hold.xml” in the same place hold.xml. activity_animation.xml… Read More »

Customizing your button or TextView or another view in ANDROID.

By | April 30, 2011

Beautifying our applications is one of the main features of your application’s success. In ANDROID there are many possible ways to do this. For eg. We need to have different colors for our buttons, However we can give backgrounds for buttons and all. But we can do many by using our custom xml files, like… Read More »

How to create and delete a directory in SdCard in ANDROID?

By | April 27, 2011

Hi all…… This is a simple example to create and delete a directory in ANDROID. Here the directly is created in the SDCARD. So first create an SDCARD and start the emulator with the SDCARD. Let’s look at the program. Use can use this program to create or delete a file in ANDROID also. main.xml… Read More »

Android frame Animation

By | April 23, 2011

A series of frames is drawn one after the other at regular intervals. For this create a xml which contains ImageView for showing the animation The main java file is Next the main part, an xml which holds each image and duration in which each image shows. The xml should be placed inside drawable folder… Read More »