gpt4 book ai didi

android - 使用 android :imeOptions ="actionNext" in Table Layout 时出现问题

转载 作者:行者123 更新时间:2023-11-29 22:29:31 26 4
gpt4 key购买 nike

我有这个表格布局,其中包含 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 在 Activity 开始时具有焦点。但是,当我在软键盘上单击下一步时,光标移动到底部行中左侧的 EditText,而不是右侧(顶部行中)的 EditText。我已经测试了顶行中右侧的 EditText,它会按照我的意愿将光标发送到底行中左侧的 EditText。

有没有办法让光标先从顶行左侧的 EditText 向右移动,然后从那里移动到底行左侧的 EditText?

如果可能的话,我还可以安排它然后将焦点移动到底行右侧的按钮吗?

谢谢

最佳答案

试试这个...

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

一旦您按下软键盘上的 NEXT 按钮,Android 就会搜索最近的可用 NEXT 文本字段来转移焦点。您可以指定应该说服搜索的方向。您还可以阅读有关 IME(Input Method Editors) options 的信息

关于android - 使用 android :imeOptions ="actionNext" in Table Layout 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4681168/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com