Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Mobile Development
  3. Android
  4. Want to automatically calculate age and date of birth...

Want to automatically calculate age and date of birth...

Scheduled Pinned Locked Moved Android
androidhelptutorial
4 Posts 4 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sabareeswara
    wrote on last edited by
    #1

    Hi... I want to do a task in android... If i enter the date of birth in a edittext then age should be calculated and if i enter the age in edittext then birth year should be calculated automatically.. This must be done without using buttons... How to do.. Help me.

    L D A 3 Replies Last reply
    0
    • S sabareeswara

      Hi... I want to do a task in android... If i enter the date of birth in a edittext then age should be calculated and if i enter the age in edittext then birth year should be calculated automatically.. This must be done without using buttons... How to do.. Help me.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Add a Listener process for the text box that checks the content. If it looks like a date of birth then calculate the age. If it looks like an age then calculate the date of birth. See http://developer.android.com/guide/topics/ui/controls/text.html[^] for more details.

      1 Reply Last reply
      0
      • S sabareeswara

        Hi... I want to do a task in android... If i enter the date of birth in a edittext then age should be calculated and if i enter the age in edittext then birth year should be calculated automatically.. This must be done without using buttons... How to do.. Help me.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        This sounds like a bad UI in the making. For example, if you wanted to enter the birth year 2003 and got the 20 entered, how would your code know that it was part of the birth year and not the age? Listening for each letter typed and trying to figure out the user's intent is not always possible and leaves room for misinterpretation.

        sabareeswara wrote:

        This must be done without using buttons

        Why?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        1 Reply Last reply
        0
        • S sabareeswara

          Hi... I want to do a task in android... If i enter the date of birth in a edittext then age should be calculated and if i enter the age in edittext then birth year should be calculated automatically.. This must be done without using buttons... How to do.. Help me.

          A Offline
          A Offline
          Awesome Sohel
          wrote on last edited by
          #4

          Put your logic in afterTextChange with help of onTextChaneListener.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups