-2

I am new to android-programming, I wanted to make an application, that shows the actual time. But I can't get it refreshed, and the phone's time, and my app's time will be different.

A part of my code:

protected override void OnCreate(Bundle savedInstance)
    {     
        this.SetTitle("Just a clock!");
        base.OnCreate(savedInstance);
        SetContentView(R.Layouts.MainLayout);
        TextView tw = FindViewById<TextView>(R.Ids.textView1);
        //tw.Click += new EventHandler(tw_Click);
        int color = Color.ParseColor("#483D8B");
        tw.SetTextColor(color);
        tw.SetTextSize(60);
        currentHour = DateTime.Now.Hour;
        currentMinute = DateTime.Now.Minute;
        tw.Text = currentHour + ":" + currentMinute;
    }

I'm looking for any working-ideas.

Thank you.

Ôry
  • 11
  • 1

1 Answers1

0

You cannot update the time this way. You need a DigitalClock or AnalogClock on your layout to do this (or TextClock for API 17).

sergiomse
  • 775
  • 12
  • 18
  • Thank you very much, is there any way, to hide the seconds? I want only HH:MM – Ôry Aug 30 '14 at 22:06
  • Yes you can but it's not obvious. I this [post](http://stackoverflow.com/questions/7610549/android-digitalclock-remove-seconds) is explained. – sergiomse Aug 30 '14 at 22:16
  • Is it possible to convert this code from java to C#? If yes, is it hard, for an android-beginner? – Ôry Aug 30 '14 at 22:20
  • Sorry I don't know how to convert this code from java to C#, I can't help with this. – sergiomse Aug 30 '14 at 22:27