本文整理汇总了Java中android.view.inputmethod.InputMethodManager.toggleSoftInput方法的典型用法代码示例。如果您正苦于以下问题:Java InputMethodManager.toggleSoftInput方法的具体用法?Java InputMethodManager.toggleSoftInput怎么用?Java InputMethodManager.toggleSoftInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.inputmethod.InputMethodManager
的用法示例。
在下文中一共展示了InputMethodManager.toggleSoftInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFoucus
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public void setFoucus(View view){
// 获取 接受焦点的资格
view.setFocusable(true);
// 获取 焦点可以响应点触的资格
view.setFocusableInTouchMode(true);
// 请求焦点
view.requestFocus();
// 弹出键盘
InputMethodManager manager=(InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
manager.toggleSoftInput(0,0);
manager.showSoftInput(view,0);
}
示例2: onClick
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public void onClick(final View widget) {
View view = LayoutInflater.from(context).inflate(R.layout.layout_input, null);
final EditText etInput = (EditText) view.findViewById(R.id.et_answer);
Button btnFillBlank = (Button) view.findViewById(R.id.btn_fill_blank);
// 显示原有答案
String oldAnswer = answerList.get(position);
if (!TextUtils.isEmpty(oldAnswer)) {
etInput.setText(oldAnswer);
etInput.setSelection(oldAnswer.length());
}
final PopupWindow popupWindow = new PopupWindow(view, LayoutParams.MATCH_PARENT, dp2px(40));
// 获取焦点
popupWindow.setFocusable(true);
// 为了防止弹出菜单获取焦点之后,点击Activity的其他组件没有响应
popupWindow.setBackgroundDrawable(new PaintDrawable());
// 设置PopupWindow在软键盘的上方
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
// 弹出PopupWindow
popupWindow.showAtLocation(tvContent, Gravity.BOTTOM, 0, 0);
btnFillBlank.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// 填写答案
String answer = etInput.getText().toString();
fillAnswer(answer, position);
popupWindow.dismiss();
}
});
// 显示软键盘
InputMethodManager inputMethodManager =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
示例3: openKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public static void openKeyboard(EditText editText, Context context) {
InputMethodManager imm = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.RESULT_SHOWN);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
InputMethodManager.HIDE_IMPLICIT_ONLY);
}
示例4: startOrCloseKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* 打开或关闭键盘
*/
public static void startOrCloseKeyboard(View view) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
// 得到InputMethodManager的实例
if (imm.isActive()) {
// 如果开启
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,
InputMethodManager.HIDE_NOT_ALWAYS);
}
}
示例5: onKey
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
habitSpinner.setOnItemSelectedListener(null);
habitSpinner.setSelection(0, false);
habitSpinner.setOnItemSelectedListener(spinnerListener);
if ((keyEvent.getAction() == KeyEvent.ACTION_UP) && (i == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager methodMan = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
methodMan.toggleSoftInput(0, 0);
ArrayList<HabitEvent> commentMatches = null;
String searchText = commentFilter.getText().toString().trim().toLowerCase(Locale.getDefault());
if (searchText.isEmpty()) {
Log.i("HabitUpDEBUG", "ViewHabitEvents/FilterENTER - search text empty");
Toast.makeText(getApplicationContext(), "Error: Please enter a string to search comments", Toast.LENGTH_SHORT).show();
return false;
} else {
ElasticSearchController.GetHabitEventsForCommentMatch commentSearch = new ElasticSearchController.GetHabitEventsForCommentMatch();
commentSearch.execute(searchText);
try {
commentMatches = commentSearch.get();
} catch (Exception e) {
Log.i("HabitUpDEBUG", "ViewHabitEvents/CommentSearch - failed to get matching HabitEvents");
}
}
events.clear();
events.addAll(commentMatches);
Collections.sort(events);
eventAdapter.notifyDataSetChanged();
}
return true;
}
示例6: toggleSoftInput
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* 切换键盘显示与否状态
*
* @param edit 输入框
*/
public static void toggleSoftInput(EditText edit) {
edit.setFocusable(true);
edit.setFocusableInTouchMode(true);
edit.requestFocus();
InputMethodManager inputManager = (InputMethodManager)
sContext.getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputManager != null) {
inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
}
示例7: onCreateView
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_item, container, false);
InputMethodManager inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
mUnbinder = ButterKnife.bind(this, view);
final RichEditorNavigation richEditorNavigation = new RichEditorNavigation(view, richEditor);
richEditorNavigation.setupRichEditor();
richEditorNavigation.setupOnClickListeners();
saveButton.setOnClickListener(this);
copyTitleButton.setOnClickListener(this);
copyDetailsButton.setOnClickListener(this);
configureAppbar(getActivity(), true);
changeAppbarTitle(getActivity(), isEditMode()
? R.string.fragment_edit_item
: R.string.add_item);
if (savedInstanceState == null) {
inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
titleEditText.requestFocus();
loadItems();
}
// Inflate the layout for this fragment
return view;
}
示例8: openKeybord
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* 打卡软键盘
*
* @param mEditText
* 输入框
* @param mContext
* 上下文
*/
public static void openKeybord(EditText mEditText, Context mContext)
{
InputMethodManager imm = (InputMethodManager) mContext
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mEditText, InputMethodManager.RESULT_SHOWN);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,
InputMethodManager.HIDE_IMPLICIT_ONLY);
}
示例9: setMainView
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
private void setMainView(){
setContentView(R.layout.activity_main);
TextView tv = (TextView) findViewById(R.id.textView2);
final EditText number = (EditText) findViewById(R.id.editText);
number.requestFocus();
InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
sb = Snackbar.make(findViewById(R.id.content_main), "Unknown error", Snackbar.LENGTH_INDEFINITE);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
final IControlChannelListener main = this;
tv.setText(Integer.toString(cc.getNumber()));
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(cc.activeCall()){
cc.hangup();
return;
}
if (number.getText().length() != 0){
cc.dial(Integer.parseInt(number.getText().toString()));
setInCallView();
}
}
});
final Button contactSelect = (Button) findViewById(R.id.buttonContact);
contactSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(contactPickerIntent, RESULT_PICK_CONTACT);
}
});
if(wakeLock.isHeld()) {
wakeLock.release();
}
}
示例10: toggleKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* 切换键盘的显示与隐藏
*
* @param activity
*/
public static void toggleKeyboard(Activity activity) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager.isActive()) {
inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
}
示例11: ShowViewQA
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public void ShowViewQA(ShowViewQACallBack showViewQACallBack){
createQAView.setVisibility(View.VISIBLE);
demoView.setVisibility(View.GONE);
focus(title);
title.setText("");
add_content.setText("");
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(title, InputMethodManager.RESULT_SHOWN);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
showViewQACallBack.ShowViewQA();
}
示例12: toggleSoftInput
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public static void toggleSoftInput(Context context) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
示例13: showKeyboardAt
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public static void showKeyboardAt(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
示例14: openKeyboard
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public static void openKeyboard(View view) {
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}
示例15: toggle
import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
* 如果输入法已经显示,那么就隐藏它;如果输入法现在没显示,那么就显示它
*/
public static void toggle(Context context) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}