【问题标题】:How can I use the android landscape keyboard buttons?如何使用 android 横向键盘按钮?
【发布时间】:2011-09-03 16:29:32
【问题描述】:

我有一个包含两个 EditText 的活动。如果在横向模式下,我选择了第一个 EditText,则显示的键盘有一个“下一步”按钮,可以让我输入第二个 EditText。同样,第二个 EditText 有一个“完成”按钮,我想处理它以完成活动。如何处理这些按钮的选择?

【问题讨论】:

    标签: android keyboard android-edittext landscape


    【解决方案1】:

    关于如何解决此问题的文档很少。我找到了一个很好的解决方案here。基本上,您可以为每个 EditTexts 添加一个 IME 选项: 对于第一个:

          android:imeOptions="actionNext"
    

    第二个:

          android:imeOptions="actionDone"
    

    要在代码中处理这些问题,请尝试以下操作:

    EditText departureAddress, destinationAddress;
    departureAddress = (EditText)findViewById(R.id.departure);
    //Set the action of the "next" button to bring destinationAddress to focus
    destinationAddress(new OnEditorActionListener(){
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
      if (actionId == EditorInfo.IME_ACTION_NEXT) {
          destinationAddress.requestFocus();
      }
      return true;
    }
      });
      destinationAddress = (EditText)findViewById(R.id.destination);
      //Set the action of the "done" button to handle the map query
      destinationAddress.setOnEditorActionListener(new OnEditorActionListener(){
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
      if (actionId == EditorInfo.IME_ACTION_DONE) {
          //Handle map query
      }
      return true;
    }
      });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-13
      • 2020-02-16
      • 1970-01-01
      相关资源
      最近更新 更多