我在我的应用程序中使用此编辑文本验证 otp。
我可以用 6 个编辑文本来做这件事,像这样my_layout.xml 是否可以使用单个编辑文本来做这件事。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:wheel="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="To complete the installation,\nplease enter the 6-digit\nverification code."
android:id="@+id/textView4"
android:textColor="@color/black"
android:gravity="center" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="1"
android:gravity="center" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="1"
android:gravity="center" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="1"
android:gravity="center" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="1"
android:layout_marginLeft="15dp"
android:gravity="center" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="1"
android:gravity="center" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLength="1"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我一直在使用BottomNavigationBar,但是我无法在onTap回调BottomNavigationBar之外以编程方式选择Tab.
以下代码使用onTap回调[哪个有效]
return new BottomNavigationBar(
items: <BottomNavigationBarItem>[
_bottomNavigationItem(Icons.account_circle, DrawerTitles.CONTACTS),
_bottomNavigationItem(Icons.delete, DrawerTitles.DELETED_CONTACTS),
_bottomNavigationItem(Icons.list, DrawerTitles.LOGS),
],
onTap: (int index) {
setState(() {
navigationIndex = index;
switch (navigationIndex) {
case 0:
handleBottomNavigationBarClicks(DrawerTitles.CONTACTS);
break;
case 1:
handleBottomNavigationBarClicks(DrawerTitles.DELETED_CONTACTS);
break;
case 2:
handleBottomNavigationBarClicks(DrawerTitles.LOGS);
break;
}
});
},
currentIndex: navigationIndex,
fixedColor: Colors.blue[400],
type: BottomNavigationBarType.fixed,
);
Run Code Online (Sandbox Code Playgroud)
但我想更改onTap回调之外的选项卡?
我尝试在onTap callBack之外更改BottomNavigatioBar使用的索引,但它没有用.
这是我试过的 -
void changeTabs(int tabIndex) {
setState(() {
navigationIndex = tabIndex;
});}
Run Code Online (Sandbox Code Playgroud)
有没有办法改变标签?
这是代码的要点
https://gist.github.com/harsh159357/62f338a196b0e5edad7aed5017dae3e5