Let’s say in a LinearLayout we have two EditText. Android system is somehow able to tell whether an EditText is the last EditText, because the “Enter” button of the soft keyboard for the first EditText is “Next”, while the “Enter” button of the soft keyboard for the second EditText is “Done”. Here is the code I use to test EditText:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout editContainer = new LinearLayout(this);
editContainer.setOrientation(LinearLayout.VERTICAL);
EditText firstEdit = new EditText(this);
firstEdit.setSingleLine(true);
EditText secondEdit = new EditText(this);
secondEdit.setSingleLine(true);
editContainer.addView(firstEdit);
editContainer.addView(secondEdit);
setContentView(editContainer);
}
Can someone tell me how I can programmatically know whether an EditText is the last one or not? Of course I can traverse the whole LinearLayout but I want to keep this approach as the last resort.
Thanks!!
The Next/Done labels are set with setImeOptions. If you want to query this value you could try getImeOptions.