当前位置: 首页>>代码示例>>Java>>正文


Java InputMethodManager.toggleSoftInput方法代码示例

本文整理汇总了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);
    }
 
开发者ID:ifadai,项目名称:SuperNote,代码行数:13,代码来源:RvEditFolderAdapter.java

示例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);
}
 
开发者ID:alidili,项目名称:Demos,代码行数:39,代码来源:FillBlankView.java

示例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);
}
 
开发者ID:JackWHLiu,项目名称:jackknife,代码行数:8,代码来源:SystemUtils.java

示例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);
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:13,代码来源:TDevice.java

示例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;
}
 
开发者ID:CMPUT301F17T29,项目名称:HabitUp,代码行数:37,代码来源:ViewHabitEventActivity.java

示例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);
    }
}
 
开发者ID:ChunweiDu,项目名称:Utils,代码行数:16,代码来源:KeyboardUtil.java

示例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;
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:30,代码来源:ItemFragment.java

示例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);
}
 
开发者ID:codeccc,项目名称:baselibrary-master,代码行数:17,代码来源:KeyBoardUtils.java

示例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();
    }
}
 
开发者ID:rctl,项目名称:CryptoVoice,代码行数:37,代码来源:Main.java

示例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);
    }
}
 
开发者ID:youth5201314,项目名称:XFrame,代码行数:12,代码来源:XKeyboardUtils.java

示例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();
}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:12,代码来源:PlaceHolderFragment.java

示例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);
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:5,代码来源:InputMethodUtils.java

示例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);
}
 
开发者ID:eventtus,项目名称:photo-editor-android,代码行数:5,代码来源:UtilFunctions.java

示例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);
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:5,代码来源:TDevice.java

示例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);
}
 
开发者ID:TIIEHenry,项目名称:TIIEHenry-Android-SDK,代码行数:8,代码来源:KeyBoardManager.java


注:本文中的android.view.inputmethod.InputMethodManager.toggleSoftInput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。