Java Android左右箭头键充当后退和上一步按钮
我正在处理一个包含多个片段的应用程序。在一个片段下,我有一些文本可编辑字段。每次用户单击此字段时,输入文本并单击左箭头键或右箭头键,在该字段中导航后,左箭头键或右箭头键充当返回或上一个按钮,导航到下一个/上一个片段(下一个/上一个屏幕) 我有以下一些自定义的xml字段Java Android左右箭头键充当后退和上一步按钮,java,android,android-fragments,android-softkeyboard,Java,Android,Android Fragments,Android Softkeyboard,我正在处理一个包含多个片段的应用程序。在一个片段下,我有一些文本可编辑字段。每次用户单击此字段时,输入文本并单击左箭头键或右箭头键,在该字段中导航后,左箭头键或右箭头键充当返回或上一个按钮,导航到下一个/上一个片段(下一个/上一个屏幕) 我有以下一些自定义的xml字段 <com.UI.widget.UIEditText android:id="@+id/userinfo_lastnameinput" android:layout_width=
<com.UI.widget.UIEditText
android:id="@+id/userinfo_lastnameinput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textCursorDrawable="@null"
android:focusable="true"
android:focusableInTouchMode="true"
android:ems="10"
android:maxLength="20"
android:textColor="@color/white"
android:imeOptions="actionDone"
android:singleLine="true"
android:inputType="textPersonName" android:paddingTop="5dp"/>
如何限制此行为,使箭头键仅在可编辑字段内移动 您还可以像这样动态创建片段
// Create new fragment and
transaction Fragment newFragment = new ExampleFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
//将fragment_容器视图中的任何内容替换为该片段,//并在需要时将事务添加到后堆栈中
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack(null);
//提交事务
transaction.commit();
只要使用
getSupportFragmentManager().beginTransaction().replace(R.id.container,fragment,“类和/或增量”);
最好在按钮下设计。只需将您的XML编码片段用作容器检查此链接以了解更多信息
transaction.commit();