Bug 697562 - Hide soft keyboard when the focus is not in awesomebar text field [r=mfinkle]

This commit is contained in:
Sriram Ramasubramanian 2011-10-26 13:47:59 -07:00
parent d512940bf9
commit 2c304c8fd3

View File

@ -43,6 +43,7 @@ import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.content.Context;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@ -50,6 +51,7 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
public class AwesomeBar extends Activity {
@ -119,6 +121,15 @@ public class AwesomeBar extends Activity {
}
}
});
text.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}
});
}
private void openUrlAndFinish(String url) {