當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。