Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

android - Can you set "tab order" in XML Layout?

I've got users with tablets that have a tab key on their soft keyboard. I am using a table view and have 3 EditText Fields in one row with EditText fields below the current row.

When the user hits tab it takes them to the next field below, not the next field to the right.

Is there a way in the layout to set the tab order or is it only done programatically?

If it can only be done in Java, how exactly is it done?

Thanks for the tip on NextFocusRight but it didn' seem to work (or I did something wrong)

Here is the code I used. I have to add the imeoptions to get the "next" button to show up in my emulator. Do you see anything wrong with the way I did this?

<EditText 
    android:id="@+id/bikeHHT"
    android:layout_width="50dip"
    android:layout_height="40dip"
    android:textSize="14px"
    android:maxLength="2"
    android:nextFocusLeft="@+id/bikeMMT"
    android:imeOptions="actionNext"
    android:layout_column="1"/>

<EditText 
    android:id="@+id/bikeMMT"
    android:layout_width="50dip"
    android:layout_height="40dip"
    android:textSize="14px"
    android:nextFocusRight="@+id/bikeSST"
    android:imeOptions="actionNext"
    android:maxLength="2"/>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Replace android:nextFocusLeft by android:nextFocusDown. The "next" soft button or the TAB key is looking for the next "down" focus and not left or right.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...