我正在嘗試爲editText創建命令,因此當您輸入關鍵字時,一些代碼將運行。我現在正在使用此代碼,但它似乎不起作用。editText'Enter'else if命令
@Override
public void editText (String editText)
{
if(editText == ("closer"))
{
((ViewGroup.MarginLayoutParams) red.getLayoutParams()).topMargin += 1;
// image.setRotation(image.getRotation() + 1);
red.requestLayout();
((ViewGroup.MarginLayoutParams) blue.getLayoutParams()).topMargin -= 1;
// image2.setRotation(image2.getRotation() + 1);
}
當我輸入單詞並按回車時,編輯文本只是創建一個新行。但我希望能夠按Enter鍵和代碼運行,輸入什麼。
怎麼樣'如果(EDITTEXT ==(」更接近「))'? –
[我如何比較Java中的字符串?](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) – 323go