android--EditText

时间:2014-02-21 12:14:00   收藏:0   阅读:339

xml代码:

bubuko.com,布布扣
<EditText
        android:id="@+id/myEdit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="122dp"
        android:ems="10" 
        android:inputType="text"
      //这里是设置软件盘Enter键显示的图标,仅是图标而已 android:imeOptions="actionSearch"/>
bubuko.com,布布扣


java代码:

bubuko.com,布布扣
myEdit=(EditText)findViewById(R.id.myEdit);
        myEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
          //判断是否点了软键盘中的enter键
if(actionId==EditorInfo.IME_ACTION_SEARCH){ Toast.makeText(MainActivity.this, "你点了--->>>search", 2).show(); } return false; } });
bubuko.com,布布扣

原文:http://www.cnblogs.com/zaqn/p/3558530.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!