Custom Keypad -- How to make these buttons functional?
<p>I have an app that I have almost finished which is a scoreboard app.  When the user does a LongClick on the score, currently a dialog box appears which shows an EditText field with an OK and CANCEL button.  When the user clicks the EditText field a keypad appears (numbers only) in which the user types in the new score, clicks DONE and then the EditText field shows the new value in the dialog box and when the user clicks OK it saves the entered value to the TextView showing the current score.</p>

<p>The problem is that I feel it is cumbersome.  Here is what I would like to happen:</p>

<ol>
<li>User does a LongClick on score</li>
<li>Keypad appears</li>
<li>User enters new score</li>
<li>User clicks OK</li>
<li>Keypad disappears and value is saved to the TextView updating the current score.</li>
</ol>

<p>In order to accomplish this, I thought of two things:</p>

<ol>
<li>I could create a new class extending View -- I'm too new to android to really understand this option.</li>
<li>I could replace the EditText in the dialog with a new XML file which is designed like a keypad.</li>
</ol>

<p>Option 2:  I figured this would probably be the easiest so I have designed the XML Layout and called it keypad.xml.  Now when the user does a LongClick the keypad.xml file inflates in a dialog with OK and CANCEL.  So far so good.  However, I don't know where I should put the code for the button actions.</p>

<p>At first thought, I figured that I could setup some onClick listener which is for ALL BUTTONS in the layout.  I figured that all buttons are going to perform the exact same function.  Basically, get the text from the button (in this case 0-9) and append it to the TextView which is just above the keypad.  Then when the user clicks OK save the TextView in keypad.xml to the current score textview.</p>

<p>Can anyone help point me in the right direction to accomplish this please?</p>

<p>Here is the screenshot of keypad.xml (there is an empty TextView above the numbers):
<img src="http://i.stack.imgur.com/pMpXD.png" alt="enter image description here"></p>

<p>Here is the XML code:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:columnCount="3" &gt;

&lt;TextView
    android:id="@+id/textView1"
    android:layout_columnSpan="3"
    android:layout_gravity="fill"
    android:gravity="right|center_vertical"
    android:textSize="24sp" /&gt;

&lt;Button android:text="1" /&gt;

&lt;Button android:text="2" /&gt;

&lt;Button android:text="3" /&gt;
&lt;Button android:text="4" /&gt;
&lt;Button android:text="5" /&gt;
&lt;Button android:text="6" /&gt;
&lt;Button android:text="7" /&gt;
&lt;Button android:text="8" /&gt;
&lt;Button android:text="9" /&gt;

&lt;Button
    android:layout_columnSpan="3"
    android:layout_gravity="fill"
    android:gravity="center"
    android:text="0" /&gt;
</code></pre>

<p></p>
