标签:
1 public class MyActivity extends Activity 2 { 3 private KeyListener listener; 4 private EditText editText; 5 6 public void onCreate(...) 7 { 8 editText = ... // Get EditText from somewhere 9 listener = editText.getKeyListener(); // Save the default KeyListener!!! 10 editText.setKeyListener(null); // Disable input 11 } 12 13 // When you click your button, restore the default KeyListener 14 public void buttonClickHandler(...) 15 { 16 editText.setKeyListener(listener); 17 } 18 }
Basically, you first save the EditText‘s default KeyListener before you call setKeyListener(null). Then, when you click your button, you call setKeyListener again, passing the default listener you previously saved.
以上是来自http://stackoverflow.com/questions/10933056/edit-text-key-listener问题中rainai的回答
好用。
标签:
原文地址:http://www.cnblogs.com/turtle920/p/4861593.html