Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid numeric keyboard
    text
    copied!<p>I am trying to add a keyboard listener...</p> <pre><code>txta1cresult.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v,int actionId, KeyEvent event) { if(actionId==EditorInfo.IME_ACTION_DONE){ calculate(); } return false; } }); </code></pre> <p>However, I am getting the following compiler error...</p> <pre><code>/home/jocala/hba1c/src/com/android/hba1c.java:82: cannot find symbol symbol : class OnEditorActionListener location: class com.jocala.hba1c.hba1c txta1cresult.setOnEditorActionListener(new OnEditorActionListener() { </code></pre> <p>This is my <code>EditText</code>...</p> <pre><code>&lt;EditText android:id="@+id/txta1cresult" android:inputType="numberDecimal" android:layout_width="80px" android:maxLength="5" android:layout_height="40px" android:textSize="18sp" android:layout_x="200px" android:layout_y="32px" &gt; &lt;/EditText&gt; </code></pre> <p>Do I need to import something other than <code>EditText</code> and <code>TextView</code>? Is there something else wrong here?</p> <pre><code> [javac] Compiling 3 source files to /home/jeff/hba1c/bin/classes [javac] /home/jeff/hba1c/src/com/android/hba1c.java:83: cannot find symbol [javac] symbol: class KeyEvent [javac] public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { [javac] ^ [javac] /home/jeff/hba1c/src/com/android/hba1c.java:84: cannot find symbol [javac] symbol: variable EditorInfo [javac] if(actionId==EditorInfo.IME_ACTION_DONE){ [javac] ^ [javac] 2 errors </code></pre> <p>2 errors remaining after fixing the import: </p> <pre><code>[javac] Compiling 2 source files to /home/jeff/hba1c/bin/classes [javac] /home/jeff/hba1c/src/com/android/hba1c.java:161: cannot find symbol [javac] symbol: class KeyEvent [javac] public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { [javac] ^ [javac] /home/jeff/hba1c/src/com/android/hba1c.java:162: cannot find symbol [javac] symbol: variable EditorInfo [javac] if(actionId==EditorInfo.IME_ACTION_DONE){ [javac] ^ [javac] 2 errors </code></pre> <p>It appears to choke on this code:</p> <pre><code>public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId==EditorInfo.IME_ACTION_DONE){ calculate(); } </code></pre> <p>Finally fixed with:</p> <p>import android.view.KeyEvent; import android.view.inputmethod.EditorInfo;</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload