设置/限制EditText只显示一行

在Layout文件中,设置android:maxLines="1"android:inputType="text"

隐藏虚拟键盘

View view = this.getCurrentFocus();if (view != null) {      InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);}

参考:
https://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard

用代码实现单击按钮

button.performClick()

如果单击有动画的话,每一步之后还需要button.invalidate

 button.performClick(); button.setPressed(true);  button.invalidate();  button.setPressed(false);  button.invalidate(); 

https://stackoverflow.com/questions/5701666/can-i-click-a-button-programmatically-for-a-predefined-intent

焦点变化事件(尚未测试)

editText.setOnFocusChangeListener(new OnFocusChangeListener() {    @Override    public void onFocusChange(View view, boolean hasFocus) {        if (hasFocus) {            Toast.makeText(getApplicationContext(), "Got the focus", Toast.LENGTH_LONG).show();        } else {            Toast.makeText(getApplicationContext(), "Lost the focus", Toast.LENGTH_LONG).show();        }    }});

更多相关文章

  1. Android(安卓)设置StatusBar的颜色
  2. Android全屏设置的两种方式
  3. android 设置系统屏幕亮度
  4. 2011.08.15(2)——— android audioManager解决MediaPlayer AudioT
  5. Android中贪吃蛇游戏的学习(三)
  6. android TextView ellipsize 只显示一个点 解决方案
  7. Android中设置分割线
  8. Android(安卓)欢迎界面设置
  9. AndroidManifest.xml - activity 详细说明

随机推荐

  1. Android学习笔记——关于onConfiguration
  2. 5分钟完全理解android handler
  3. 开启andriod手机的adbd,进行无线adb调试
  4. android 软键盘的弹出问题总结
  5. android M 运行时权限申请流程
  6. android的Application使用
  7. Android CountDownTimer倒计时器的使用
  8. ADT下载地址(含各版本),最新ADT-23.0.6
  9. android没有插SD卡/TF卡(TF卡其实就是micr
  10. 关于android的ListView的getCheckItemIds