How many days are left until Christmas Tutorials

Android Studio Tutorial How many days are left until Christmas 2018

Straightforward Tutorial step by step with free source code: rely days from the second you open the app until the settled date, in Android Studio version 3.1.three. For this tutorial, I counted the remaining days, hours, minutes and seconds until the Christmas 2018.

Create new challenge with Software identify: Days until Christmas; Minimal SDK: API 21 – Android 5 (Lollipop).

Add 2 footage, one for app background and one for countdown background, in res->drawable folder.

In manifest->AndroidManifest.xml write the code:

In app->res->values->strings.xml write the code:

Days until Christmas
There are only
until Christmas!

In app->res->layout->activity_main.xml write the code:

In app->java-> write the code:

package deal;

import android.os.Bundle;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.os.Handler;
import android.view.View;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity

personal TextView txtTimerDay, txtTimerHour, txtTimerMinute, txtTimerSecond;
personal TextView tvEvent;
personal Handler handler;
personal Runnable runnable;

protected void onCreate(Bundle savedInstanceState)

txtTimerDay = (TextView) findViewById(;
txtTimerHour = (TextView) findViewById(;
txtTimerMinute = (TextView) findViewById(;
txtTimerSecond = (TextView) findViewById(;
tvEvent = (TextView) findViewById(;


public void countDownStart()
handler = new Handler();
runnable = new Runnable()
public void run()
handler.postDelayed(this, 1000);
SimpleDateFormat dateFormat = new SimpleDateFormat(
// Please here set your event date//YYYY-MM-DD
Date futureDate = dateFormat.parse(“2018-12-25”);
Date currentDate = new Date();
if (!currentDate.after(futureDate))
lengthy diff = futureDate.getTime()
– currentDate.getTime();
lengthy days = diff / (24 * 60 * 60 * 1000);
diff -= days * (24 * 60 * 60 * 1000);
long hours = diff / (60 * 60 * 1000);
diff -= hours * (60 * 60 * 1000);
lengthy minutes = diff / (60 * 1000);
diff -= minutes * (60 * 1000);
lengthy seconds = diff / 1000;
txtTimerDay.setText(“” + String.format(“%02d”, days));
txtTimerHour.setText(“” + String.format(“%02d”, hours));
+ String.format(“%02d”, minutes));
+ String.format(“%02d”, seconds));

tvEvent.setText(“The event started!”);

catch (Exception e)

handler.postDelayed(runnable, 1 * 1000);

public void textViewGone()

Run app in cellular gadget or Emulator (API 21 – Android 5) and see how many days are left until Christmas 2018, in format landscape.

Comply with video tutorial:

Obtain this app totally free and set up it on your cellular gadget to see how it works:

Obtain challenge with Supply Code from here:

Please subscribe right here to our YouTube channel. Thank you!
Examine subsequent tutorials to study all about Android.
For additional questions depart a message.