public void run() { freshestEditText.onEditorAction(imeAction); } });
final EditText editText = (EditText) findViewById(R.id.textView); editText.setOnEditorActionListener(clickedEnter); Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { editText.onEditorAction(EditorInfo.IME_ACTION_DONE); } });
public void run() { freshestEditText.onEditorAction(imeAction); } });
public void pressSoftKeyboardNextButton(){ final EditText freshestEditText = viewFetcher.getFreshestView(viewFetcher.getCurrentViews(EditText.class)); if(freshestEditText != null){ inst.runOnMainSync(new Runnable() { public void run() { freshestEditText.onEditorAction(EditorInfo.IME_ACTION_NEXT); } }); } }
@Override public void onEditorAction(int actionCode) { super.onEditorAction(actionCode); if (actionCode == EditorInfo.IME_ACTION_DONE) { clearFocus(); } } }
@Override public void onEditorAction(int actionCode) { super.onEditorAction(actionCode); if (actionCode == EditorInfo.IME_ACTION_DONE) { clearFocus(); } } }
public void testImeNext() throws Exception { //Grab a reference to your EditText. This code grabs the first Edit Text in the Activity //Alternatively, you can get the EditText by resource id or using a method like getCurrentEditTexts() //Make sure it's final, we'll need it in a nested block of code. final EditText editText = solo.getEditText(0); //Create a runnable which triggers the onEditorAction callback Runnable runnable = new Runnable() { @Override public void run() { editText.onEditorAction(EditorInfo.IME_ACTION_NEXT); } }; //Use Solo to get the current activity, and pass our runnable to the UI thread. solo.getCurrentActivity().runOnUiThread(runnable); }
/** * This will send the NEXT action to simulate pressing next on the keyboard. * Because it has to be run on the UI thread we use a barrier to block and * stop this request returning until the action is complete. **/ private void sendIMENext(final EditText editText) throws Exception { final CyclicBarrier barrier = new CyclicBarrier(2); Runnable runnable = new Runnable() { @Override public void run() { editText.onEditorAction(EditorInfo.IME_ACTION_NEXT); try { barrier.await(); } catch (Exception e) { Log.e("MainActivityTest", "Interupted on UI thread pressing IME next", e); } } }; //Use Solo to get the current activity, and pass our runnable to the UI thread. solo.getCurrentActivity().runOnUiThread(runnable); // Waits until the barrier is met in the runnable barrier.await(); }
public static void pressEnter(Instrumentation instrumentation, final EditText editText) { instrumentation.runOnMainSync(new Runnable() { @Override public void run() { editText.onEditorAction(EditorInfo.IME_ACTION_DONE); } }); instrumentation.waitForIdleSync(); }