LinearLayout mLinearLayout = new LinearLayout(this); mLinearLayout = (LinearLayout)findViewById(R.id.mylinearlayout); Button lButton = (Button)findViewById(R.id.mybtnid); lButton.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { EditText lEditText = new EditText(this); lEditText .setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); lEditText.SetText("Text Here"); mLinearLayout.addView(lEditText); EditorInfo ed = new EditorInfo(); ed.inputType = InputType.TYPE_CLASS_PHONE; lEditText.setInputType(ed.inputType); InputFilter[] FilterArray = new InputFilter[1]; FilterArray[0] = new InputFilter.LengthFilter(6); lEditText.setFilters(FilterArray);
attribute.dump(new Printer() {
public static void performEditorAction(@Nullable Object action) throws AppiumException { ViewInteraction viewInteraction; try { viewInteraction = onView(hasFocus()); } catch (NoMatchingViewException e) { throw new InvalidElementStateException(String.format("Currently there is no focused " + "element to perform %s editor action on", action == null ? "the default" : action), e); } if (action == null) { logger.debug("Performing the default editor action on the focused element"); try { viewInteraction.perform(pressImeActionButton()); return; } catch (PerformException e) { throw new InvalidElementStateException("Cannot perform the default action " + "on the focused element"); } } int actionCode = toActionCode(action); logger.debug(String.format("Performing editor action %s on the focused element", actionCode)); View view = new ViewGetter().getView(viewInteraction); InputConnection ic = view.onCreateInputConnection(new EditorInfo()); if (!ic.performEditorAction(actionCode)) { throw new InvalidElementStateException(String.format("Cannot perform editor action %s " + "on the focused element", action)); } } }