title: Converting common Android countdown timer example to accept user input
body: <p>Learning ADT, coming from C/HTML/CSS/JS background primarily in xCode and Linux (Nano preferred).  I'm having some troubles adapting and hoping I can get some pointers on how to wrap my head around the differences in these very simple first steps.</p>
  
  <p>I'm working with one of the very common variations on Wagied Davids "Android Cookbook" example:</p>
  
  <p><a href="http://androidbite.blogspot.com/2012/11/android-count-down-timer-example.html" rel="nofollow noreferrer">http://androidbite.blogspot.com/2012/11/android-count-down-timer-example.html</a></p>
  
  <p>My self-assigned task is to use this as basis for a simple egg-timer app (going back to FroYo) where the user enters the time they want to count down from in an EditText (instead of the fixed 30 seconds.)</p>
  
  <p>I made the following changes to the layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" &gt;
  &lt;TextView
      android:id="@+id/instruction"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:text="Enter countdown time:"
      android:textSize="25sp" /&gt;
  
  &lt;TextView
      android:id="@+id/timer"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:paddingRight="10dip"
      android:textSize="50dp" /&gt;
  
  &lt;Button
      android:id="@+id/button"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:padding="10dip"
      android:text="Start" /&gt;
  &lt;--Here's the part I added, SO!--&gt;
  &lt;EditText
      android:id="@+id/time"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/instruction"
      android:layout_centerHorizontal="true"
      android:ems="10"
      android:imeOptions="actionGo"
      android:inputType="number" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>But the next step in the main java activity eludes me.  I changed the definition of <code>startTime</code> to <code>public long</code> from <code>private final long</code> and have essentially been working with a chunk of code like this:</p>
  
  <pre><code>//get countdown interval from user
  EditText myEdit = (EditText) findViewById(R.id.time);
  //convert edit text to string 
  String numString = myEdit.getText().toString();
  //convert string to integer
  myInt = Integer.parseInt(numString);
  //convert integer to long number of milliseconds
  long localStartTime = (Long.valueOf(myInt) * 1000);
  </code></pre>
  
  <p>I've tried making it its own class in the activity file and returning the <code>localStartTime</code>
  then assigning that to <code>startTime</code>, calling it from both <code>onCreate</code> which crashes, and <code>onClick</code>(which just counts down from the initially defined value of <code>startTime</code>.) I've also tried it as a direct code snippet in <code>onCreate</code> so the last line looks kind of like:
  <code>startTime = (Long.valueOf(myInt) * 1000);</code>
  before calling <code>countDownTimer = new MyCountDownTimer(startTime, interval);</code> but this again just lets you enter the text but won't countdown from what I think I've assigned to the <code>startTime</code> variable.</p>
  
  <p>I also tried a variation on Ken Wolf's answer here:
  <a href="https://stackoverflow.com/questions/16996865/android-java-edittext-to-int">Android java EditText to int</a>
  placing the try-and-catch in the <code>onCreate</code> but again could enter a time without counting down from it when you hit the start button.</p>
  
  <p>If you've chosen to read all this already, thank you, and I would request of you that you concentrate on two things in answering this question.  First, as simple as it may seem to an experienced Java programmer, how would you approach this?  Second, what are the ways of thinking about Android Java that I'm missing from the C/JavaScript mindsets that are standing in my way?</p>
  
  <p>Thank you.</p>