1

3つのEditTextフィールドと計算を実行するボタンを備えたこのテーブルレイアウトがあります。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <TextView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="@string/lbl_fuel_order"
  android:textSize="18dp"
  android:gravity="center_horizontal"/>
 <TableLayout
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:stretchColumns="*">
  <TableRow>
   <TextView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="@string/lbl_arr_kgs"
    android:textSize="12dp"
    android:layout_weight="1"/>
   <TextView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="@string/lbl_sg"
    android:textSize="12dp"
    android:layout_weight="1"/>
  </TableRow>
  <TableRow>
   <EditText
    android:id="@+id/arr_fuel"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:lines="1"
    android:inputType="number"
    android:imeOptions="actionNext"/>
   <EditText
    android:id="@+id/sg"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:lines="1"
    android:inputType="numberDecimal"
    android:imeOptions="actionNext"/>
  </TableRow> 
  <TableRow>
   <TextView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="@string/lbl_req_tanks_kgs"
    android:textSize="12dp"
    android:layout_weight="1"/>
  </TableRow>
  <TableRow>
   <EditText
    android:id="@+id/req_tanks_fuel"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:lines="1"
    android:inputType="number"
    android:imeOptions="actionNext"/>
   <Button
    android:id="@+id/btn_calc_fuel_order"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="@string/lbl_calc"/>
  </TableRow>
  <TableRow>
   <TextView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="@string/lbl_uplift_kgs"
    android:textSize="12dp"
    android:layout_weight="1"/>
   <TextView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:text="@string/lbl_uplift_l"
    android:textSize="12dp"
    android:layout_weight="1"/>
  </TableRow>
  <TableRow>
   <TextView
    android:id="@+id/req_weight"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="left"
    android:lines="1"
    android:text="000000"
    android:textSize="24dp"
    android:textColor="#ff0000"/>
   <TextView
    android:id="@+id/req_volume"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="left"
    android:lines="1"
    android:text="111111"
    android:textSize="24dp"
    android:textColor="#00ff00"/>
  </TableRow>
 </TableLayout>
    </LinearLayout>

テーブルレイアウトの一番上の行にある左側のEditTextは、アクティビティの開始時にフォーカスがあります。ただし、ソフトキーボードの[次へ]をクリックすると、カーソルは右側(上の行)のEditTextではなく、下の行の左側のEditTextに移動します。上の行の右側のEditTextをテストしました。これにより、下の行の左側のEditTextにカーソルが送られます。

最初に上の行の左側のEditTextからカーソルを右に移動し、次に下の行の左側のEditTextにカーソルを移動する方法はありますか?

それが可能であれば、下の行の右側にあるボタンにフォーカスを移動するように調整することもできますか?

ありがとう

4

3 に答える 3

2

これを試して...

TextView nextField = (TextView)currentField.focusSearch(View.FOCUS_RIGHT);
nextField.requestFocus();

ソフト キーボードの [次へ] ボタンを押すと、Android は最も近い使用可能な次のテキスト フィールドを検索してフォーカスを移動します。検索を説得する方向を指定できます。IME(Input Method Editors)オプションについても読むことができます

于 2011-02-14T18:20:15.853 に答える