キーボードリスナーを追加しようとしています...
txta1cresult.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v,int actionId, KeyEvent event) {
if(actionId==EditorInfo.IME_ACTION_DONE){
calculate();
}
return false;
}
});
ただし、次のコンパイラエラーが発生します...
/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() {
これは私のEditText
...
<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"
>
</EditText>
EditText
および以外のものをインポートする必要がありTextView
ますか?ここに何か問題がありますか?
[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
インポートを修正した後に残っている2つのエラー:
[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
このコードで窒息しているようです:
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId==EditorInfo.IME_ACTION_DONE){
calculate();
}
最後に修正されました:
import android.view.KeyEvent; import android.view.inputmethod.EditorInfo;
ありがとう!