zoukankan      html  css  js  c++  java
  • android:imeOptions

    转自:http://www.cnblogs.com/qiengo/archive/2012/05/03/2480857.html

    默认情况下软键盘右下角的按钮为“下一个”,点击会到下一个输入框,保持软键盘


     

    设置 android:imeOptions="actionDone" ,软键盘下方变成“完成”,点击后光标保持在原来的输入框上,并且软键盘关闭


     

    android:imeOptions="actionSend" 软键盘下方变成“发送”,点击后光标移动下一个
    在这里设置的imeOptions如何使用呢?如下面的代码,让EditText实现setOnEditorActionListener,在onEditAction方法中actionId就对应我们设置的imeOptions。系统默认的actionId有:EditorInfo.IME_NULL、EditorInfo.IME_ACTION_SEND、EditorInfo.IME_ACTION_DONE等。这样我们就可以根据不同的EditText来实现不同的软键盘右下角功能键。
    复制代码
    package com.test;
    
    import com.test.main.TestAsyn;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.inputmethod.EditorInfo;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.TextView.OnEditorActionListener;
    import android.widget.Toast;
    
    public class IMFActivity extends Activity implements OnEditorActionListener {
    
    EditText etDefault;
    EditText etEmail;
    EditText etNumber;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.imf_layout);
    
    etDefault = (EditText)findViewById(R.id.default_content);
    etEmail = (EditText)findViewById(R.id.email_content);
    etNumber = (EditText)findViewById(R.id.number_content);
    etDefault.setOnEditorActionListener(this);
    etEmail.setOnEditorActionListener(this);
    etNumber.setOnEditorActionListener(this);
    
    }
    
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    switch(actionId){
    case EditorInfo.IME_NULL:
    System.out.println("null for default_content: " + v.getText() );
    break;
    case EditorInfo.IME_ACTION_SEND:
    System.out.println("action send for email_content: " + v.getText());
    break;
    case EditorInfo.IME_ACTION_DONE:
    System.out.println("action done for number_content: " + v.getText());
    break;
    }
    //Toast.makeText(this, v.getText()+"--" + actionId, Toast.LENGTH_LONG).show();
    return true;
    }
    }
  • 相关阅读:
    A very good site containing a lot of wonderful videos from Microsoft, List_of_GUI_testing_tools,
    java试用(3)awt,UI
    deletion of pointer to incomplete type 'A'; no destructor called
    windbg
    semaphore与Mutex
    Display a Web Page in a Plain C Win32 Applicatio
    java试用(1)hello world
    Linux opensshserver,
    Toggle hardware data/read/execute breakpoints programmatically
    RTThread RTOS
  • 原文地址:https://www.cnblogs.com/leihupqrst/p/3289400.html
Copyright © 2011-2022 走看看