vijay
5/20/2015 - 7:33 AM

Virtual softkeypad

Virtual softkeypad

//bhai this is the action on soft keypad Submit Button

EditTextOtp.setImeActionLabel("Submit", KeyEvent.KEYCODE_ENTER);
EditTextOtp.setImeOptions(EditorInfo.IME_ACTION_GO);

EditTextOtp.setOnEditorActionListener(new OnEditorActionListener() {
			public boolean onEditorAction(TextView v, int actionId,
					KeyEvent event) {
					  
					  /*if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
						|| (actionId == EditorInfo.IME_ACTION_GO))*/

				if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
					// -------------------------------------------
					submitAction();
					// --------------------------------------------
				}
				return false;
			}
		});
//bhai this is the action on soft keypad Go Button

/*implements OnEditorActionListener*/
//edtAuth.setOnEditorActionListener(this);

@Override
	public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

		if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
				|| (actionId == EditorInfo.IME_ACTION_DONE)) {
			goButton();
		}

		return false;
	}
//Method used to hide keypad from view
//bhai you can find view by this.getCurrentFocus()
public static void hideKeyPad(Context ctx, View v) {
		try {
			InputMethodManager imm = (InputMethodManager) ctx
					.getSystemService(Context.INPUT_METHOD_SERVICE);
			if (v instanceof ViewGroup) {
				ViewGroup group = (ViewGroup) v;
				for (int i = 0; i < group.getChildCount(); i++) {
					hideKeyPad(ctx, group.getChildAt(i));
				}
			} else {
				if (v instanceof EditText)
					imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
			}
		} catch (Exception e) {
		}
	}