android.widget.TextView.getWindowToken()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(192)

本文整理了Java中android.widget.TextView.getWindowToken()方法的一些代码示例,展示了TextView.getWindowToken()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.getWindowToken()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:getWindowToken

TextView.getWindowToken介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

class DoneOnEditorActionListener implements OnEditorActionListener {
  @Override
  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
      InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
      return true;  
    }
    return false;
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
 if (event == null || event.getAction() == KeyEvent.ACTION_UP) {
  searchFor(search.getText().toString());
  InputMethodManager imm=
    (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
 }
 return(true);
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
 if (event == null || event.getAction() == KeyEvent.ACTION_UP) {
  adapter.add(v.getText().toString());
  v.setText("");
  InputMethodManager imm=
    (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
 }
 return(true);
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
 if (event == null || event.getAction() == KeyEvent.ACTION_UP) {
  adapter.add(v.getText().toString());
  v.setText("");
  InputMethodManager imm=
    (InputMethodManager)getActivity()
      .getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
 }
 return(true);
}

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

@Override
  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    //当actionId == XX_SEND 或者 XX_DONE时都触发
    //或者event.getKeyCode == ENTER 且 event.getAction == ACTION_DOWN时也触发
    //注意,这是一定要判断event != null。因为在某些输入法上会返回null。
    if (actionId == EditorInfo.IME_ACTION_GO
        || actionId == EditorInfo.IME_ACTION_DONE
        || (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode()
        && KeyEvent.ACTION_DOWN == event.getAction())) {
      if (urlText.getText().length() > 0) {
        loadUrl(v.getText() + "");
        InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
          imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        }
      }
      //处理事件
    }
    return false;
  }
});

代码示例来源:origin: Flipboard/bottomsheet

imm.hideSoftInputFromWindow(shareText.getWindowToken(), 0);

代码示例来源:origin: chiuki/advanced-textview

private void hideSoftKeyboard() {
  InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
 }
}

代码示例来源:origin: ukanth/afwall

@Override
  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
      InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
      String s = mHexVal.getText().toString();
      if (s.length() > 5 || s.length() < 10) {
        try {
          int c = ColorPickerPreference.convertToColorInt(s.toString());
          mColorPicker.setColor(c, true);
          mHexVal.setTextColor(mHexDefaultTextColor);
        } catch (IllegalArgumentException e) {
          mHexVal.setTextColor(Color.RED);
        }
      } else {
        mHexVal.setTextColor(Color.RED);
      }
      return true;
    }
    return false;
  }
});

代码示例来源:origin: stackoverflow.com

class DoneOnEditorActionListener implements OnEditorActionListener {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
  if (actionId == EditorInfo.IME_ACTION_DONE) {
    InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
    return true;    
  }
  return false;
}

代码示例来源:origin: stackoverflow.com

class DoneOnEditorActionListener implements OnEditorActionListener {
   @Override
   public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
     if (actionId == EditorInfo.IME_ACTION_DONE) {
       InputMethodManager imm = (InputMethodManager) v.getContext()
           .getSystemService(Context.INPUT_METHOD_SERVICE);
       imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
       return true;
     }
     return false;
   }
 }

代码示例来源:origin: stackoverflow.com

class DoneOnEditorActionListener implements OnEditorActionListener {

  @Override
  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    // TODO Auto-generated method stub
    if (actionId == EditorInfo.IME_ACTION_DONE) {
      InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
      return true;
    }
    return false;
  }
}

代码示例来源:origin: stackoverflow.com

class DoneOnEditorActionListener implements OnEditorActionListener {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
  if (actionId == EditorInfo.IME_ACTION_DONE) {
    InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
    return true;    
  }
  return false;
}

代码示例来源:origin: stackoverflow.com

mEtNumber.setOnEditorActionListener(new TextView.OnEditorActionListener() {
     @Override
     public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
       if (actionId == EditorInfo.IME_ACTION_DONE) {
         // do something, e.g. set your TextView here via .setText()
         InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
         imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
         return true;
       }
       return false;
     }
   });

代码示例来源:origin: stackoverflow.com

mEditText.setOnEditorActionListener(new OnEditorActionListener(){
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
      mButton.performClick();
      InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
      v.setText("");
      return true;
    }
});

代码示例来源:origin: stackoverflow.com

actv = (AutoCompleteTextView)findViewById(R.id.actv);
   actv.setOnEditorActionListener(new OnEditorActionListener() {
     @Override
     public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
       if (actionId == EditorInfo.IME_ACTION_DONE) {
         InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
         imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
         return true;    
       }
       return false;
     }           
   });

代码示例来源:origin: stackoverflow.com

@Override
   public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
     if (actionId == EditorInfo.IME_ACTION_DONE) {
       // do something, e.g. set your TextView here via .setText()
       InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
       imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
       return true;
     }
     return false;
   }
 });

代码示例来源:origin: opentok/opentok-android-sdk-samples

@Override
  public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
      InputMethodManager inputMethodManager = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
      inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
      sendMessage();
      return true;
    }
    return false;
  }
});

代码示例来源:origin: TUM-Dev/Campus-Android

private void hideKeyboard() {
  InputMethodManager inputManager =
      (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  if (inputManager != null) {
    inputManager.hideSoftInputFromWindow(titleView.getWindowToken(),0);
  }
}

代码示例来源:origin: easemob/kefu-android-demo

public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_SEND || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
      InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
      assert imm != null;
      imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
      itemTheme.clearFocus();
      return true;
    }
    return false;
  }
});

代码示例来源:origin: mkulesh/microMathematics

protected void closeDialog(boolean hideKeyboard)
{
  if (hideKeyboard && !ViewUtils.isHardwareKeyboardAvailable(getContext()))
  {
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    ViewUtils.Debug(this, "request to hide keyboard from dialog");
    imm.hideSoftInputFromWindow(title.getWindowToken(), 0);
  }
  dismiss();
}

相关文章

TextView类方法