Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid select another edit text onKeyListener
    text
    copied!<p>I have a table layout that I dynamically insert a couple of extra rows into. I set the <code>android:imeOptions="actionNext"</code>. My listener code is below:</p> <pre><code>textKind.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == event.KEYCODE_ENTER){ ((EditText)findViewById(5+v.getId())).requestFocus(); } return false; } }); </code></pre> <p>I want to have a specific edit text request focus if I tap the <code>Next</code> button on the soft keyboard. The code below shows how I assign my id's:</p> <pre><code>textKind.setId(columnNumberCount); textVariety.setId(columnNumberCount+5); textCode.setId(columnNumberCount+10); textArea.setId(columnNumberCount+15); textPathogen.setId(columnNumberCount+20); textDegree.setId(columnNumberCount+25); textSample.setId(columnNumberCount+30); textCrop.setId(columnNumberCount+35); textGeneral.setId(columnNumberCount+40); this.columnNumber++; </code></pre> <p>I have set it up so that I can add a max of four columns. That is why I set the id as the <code>count + 5</code>. At the moment the next button navigates the cursor right and not down (with all columns added). Does anyone have suggestions? Thanks</p> <p><strong>Edit</strong></p> <p>I changed my code to detect the enter button correctly:</p> <pre><code>textKind.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // TODO Auto-generated method stub if (actionId == EditorInfo.IME_ACTION_NEXT){ Toast.makeText(getApplicationContext(), "Enter pressed", Toast.LENGTH_LONG).show(); ((EditText)findViewById(5+v.getId())).requestFocus(); } return false; } }); </code></pre> <p>The focus still doesn't go to the next edit text.</p> <p><strong>Edit - A graphical description of my issue</strong></p> <p><img src="https://i.stack.imgur.com/XdWat.png" alt="enter image description here"></p> <p>At the moment the cursor moves to the edit text on the right. I want the cursor to move down and not right.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload