Android:EditText NextFocusDown不会触发Spinner

Android:EditText NextFocusDown不会触发Spinner,第1张

概述在我的应用程序中,我有一个注册屏幕,有很多EditTexts和Spinners. 我想逐一浏览“注册”字段. 所以我应用了android:imeOptions =“actionNext”.但它忽略了所有的Spinners.它将仅关注EditText.我也试过setNextFocusDownId().这也忽略了纺纱厂. <LinearLayout xmlns:android="htt 在我的应用程序中,我有一个注册屏幕,有很多EditTexts和Spinners.
我想逐一浏览“注册”字段.

所以我应用了android:imeOptions =“actionNext”.但它忽略了所有的Spinners.它将仅关注EditText.我也试过setNextFocusDownID().这也忽略了纺纱厂.

<linearLayout        xmlns:androID="http://schemas.androID.com/apk/res/androID"        androID:ID="@+ID/reportentry11"        androID:layout_wIDth="fill_parent"        androID:layout_height="wrap_content"        androID:orIEntation="vertical" >        <EditText            androID:ID="@+ID/numbers"            androID:layout_wIDth="fill_parent"            androID:layout_height="wrap_content"            androID:imeOptions="actionNext"            androID:inputType="phone"             >           <requestFocus/>        </EditText>        <linearLayout            xmlns:androID="http://schemas.androID.com/apk/res/androID"            androID:ID="@+ID/reportentry12"            androID:layout_wIDth="fill_parent"            androID:layout_height="wrap_content"            androID:orIEntation="horizontal"            >            <TextVIEw                androID:ID="@+ID/txt_exp"                androID:layout_wIDth="fill_parent"                androID:layout_height="fill_parent"                androID:text="EXP:"                androID:textcolor="#000000"                androID:textSize="12dp" />            <Spinner                androID:ID="@+ID/spin_date"                androID:layout_wIDth="fill_parent"                androID:layout_height="fill_parent"                androID:layout_weight="3"                androID:focusable="true"                androID:focusableIntouchMode="true"                androID:nextFocusDown="@+ID/spin_year"                androID:text="date"                androID:textSize="12dp" />            <Spinner                androID:ID="@+ID/spin_year"                androID:layout_wIDth="fill_parent"                androID:layout_height="fill_parent"                androID:layout_marginRight="5dp"                  androID:nextFocusDown="@+ID/cvc"                androID:text="year"                androID:textSize="12dp" />        </linearLayout>        <EditText            androID:ID="@+ID/cvc"            androID:layout_wIDth="fill_parent"            androID:layout_height="fill_parent"            androID:hint="@string/reg_label_cvc"            androID:imeOptions="actionNext"            androID:inputType="phone" />        <EditText            androID:ID="@+ID/fname"            androID:layout_wIDth="fill_parent"            androID:layout_height="wrap_content"            androID:hint="@string/reg_label_fname"            androID:imeOptions="actionNext" />        <EditText            androID:ID="@+ID/address"            androID:layout_wIDth="fill_parent"            androID:layout_height="wrap_content"            androID:hint="@string/reg_label_address"            androID:imeOptions="actionNext" />        <EditText            androID:ID="@+ID/city"            androID:layout_wIDth="fill_parent"            androID:layout_height="wrap_content"            androID:hint="@string/reg_label_city"            androID:imeOptions="actionNext"            androID:nextFocusDown="@+ID/pr_spin" />        <linearLayout            xmlns:androID="http://schemas.androID.com/apk/res/androID"            androID:ID="@+ID/reportentry13"            androID:layout_wIDth="fill_parent"            androID:layout_height="wrap_content"            androID:orIEntation="horizontal" >            <TextVIEw                androID:ID="@+ID/txt_pr"                androID:layout_wIDth="fill_parent"                androID:layout_height="fill_parent"                androID:text="PROV:"                androID:textcolor="#000000"                androID:textSize="12dp" />            <Spinner                androID:ID="@+ID/pr_spin"                androID:layout_wIDth="fill_parent"                androID:layout_height="fill_parent"                androID:text="date"                androID:imeOptions="actionNext"                androID:textSize="14dp" />            <EditText                androID:ID="@+ID/pcode"                androID:layout_wIDth="fill_parent"                androID:layout_height="fill_parent"                androID:hint="@string/reg_label_pcode"                androID:imeOptions="actionDone" />        </linearLayout>        <button            androID:ID="@+ID/register_register_button"            androID:layout_wIDth="wrap_content"            androID:background="@drawable/green_button_bg"            androID:onClick="completeClicked"            androID:text="@string/reg_label_complete"            androID:textSize="28dp"            androID:textStyle="bold" />    </linearLayout>

请为我提供触发纺纱厂的最佳方法.

解决方法 在你的编辑文本上,覆盖onEditorAction并给予焦点(或做任何事情,比如打开你的微调器)……
yourEditTXT.setonEditorActionListener(new OnEditorActionListener() {    @OverrIDe    public boolean onEditorAction(TextVIEw vIEw,int actionID,KeyEvent event) {            if (actionID == EditorInfo.IME_ACTION_NEXT) {                //do your stuff here...                return true;            }            return false;     }});

编辑12/4:
我发现你昨晚仍然在努力解决这个问题,如果你没有找到解决方案(并且没有发布一个解决方案)或帮助其他人阅读本文,这可能有助于从微调器中编辑文本.

mySpinner.setonItemSelectedListener(new MyOnItemSelectedListener());            public class MyOnItemSelectedListener implements OnItemSelectedListener {        public voID onItemSelected(AdapterVIEw<?> parentvIEw,VIEw v,int position,long ID) {            // your spinner proces code             // then when you are done,yourEditText.setFocusableIntouchMode(true);  //if this is not already set            yourEditText.requestFocus();  //to move the cursor            final inputMethodManager inputMethodManager = (inputMethodManager) context.getSystemService(Context.input_METHOD_SERVICE);            inputMethodManager.showSoftinput(yourEditText,inputMethodManager.SHOW_IMPliCIT);  // this line and the one above will open the soft keyboard if it doesn't already open        }        public voID onnothingSelected(AdapterVIEw<?> arg0) { }    };
总结

以上是内存溢出为你收集整理的Android:EditText NextFocusDown不会触发Spinner全部内容,希望文章能够帮你解决Android:EditText NextFocusDown不会触发Spinner所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1130283.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存