本文整理匯總了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);
}