I have a series of EditText entries and would like it so when the user hits the enter key it will go to the next Editext. I know how do this one at a time but is there a way to tell all of the edittext controls to use the same function that checks the key entry and advances the cursor. It seems kind of crazy to have one function for each of the EditTexts
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Adding
in XML is just enough. When You are not defining input type, then it goes to next line.
For an alternative or a newer approach for the answer given from Yoni...
Since
singleLine
is considereded deprecated, we can set manually toandroid:maxLines="1"
withandroid:inputType="text"
.Small explanation:
android:inputType="text"
to specifically treat the input as plain text.android:maxLines="1"
to set the max lines of the text to 1 (as it suggests).Using
maxLines="1"
alone, will not cause any effect, butinputType="text"
alone may work also, as Adam mentions (though I haven't checked this).Add the following lines in EditText
You could try adding a single event listener to all your editText objects:
Much simpler than sniffing keys: try setting
android:singleLine="true"
andandroid:imeOptions="actionNext"
(at least for single-line entry textviews). Read more in the Android documentation for TextView.Update:
singleLine
is deprecated now, but you can leave it out. It's the default behavior for editable text as long as you don't explicitly setandroid:inputType="textMultiLine"
, andinputType
overrides the suggestedsingleLine
replacement ofmaxLines="1"
for editable text anyways.Apply this custom style in styles.xml
and then set it in EditText like this