BottomNavigationBarItem(icon: Icon(Icons.monetization_on), title: Text('Page3')),
BottomNavigationBarItem(icon: Icon(Icons.accessibility), title: Text('Page4'))
],
);
}
onTabTapped(int index) {
setState(() {});
_currentIndex=index;
}
}
class _MyHomePageState extends State {
@override
void initState() {
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
bottomNavigationBar: BotNavBarWidget(),
body: Container(),
);
}
}
底部导航切换page
BotNavBarWidget 底部导航
class BotNavBarWidget extends StatefulWidget {
final ValueChanged stackValue;
BotNavBarWidget({Key key, this.stackValue}) : super(key: key);
@override
_BotNavBarWidgetState createState() => _BotNavBarWidgetState();
}
class _BotNavBarWidgetState extends State {
List tabInt = [0];
int _currentIndex = 0;
List _botNavBarItems = [
BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('Page1')),
BottomNavigationBarItem(icon: Icon(Icons.payment), title: Text('Page2')),
BottomNavigationBarItem(
icon: Icon(Icons.monetization_on), title: Text('Page3')),
BottomNavigationBarItem(
icon: Icon(Icons.accessibility), title: Text('Page4'))
];
@override
Widget build(BuildContext context) {
return BottomNavigationBar(
type: BottomNavigationBarType.fixed,
onTap: onTabTapped,
currentIndex: _currentIndex,
backgroundColor: Colors.lightBlueAccent,
//selectedItemColor: Colors.black,
unselectedItemColor: Colors.red,
elevation: 0.0,
fixedColor: Colors.black,
showUnselectedLabels: true,
items: _botNavBarItems,
);
}
onTabTapped(int index) {
setState(() {});
_currentIndex = index;
if (!tabInt.contains(index)) {
tabInt.add(index);
}
if (widget.stackValue != null) {
widget.stackValue(_currentIndex,tabInt);
}
}
}
typedef ValueChanged = void Function(
int currentIndex,
List tabInt,
);
StackWidget 容纳多个page的容器
class StackWidget extends StatefulWidget {
StackWidget({Key key, this.currentIndex = 0, this.tabInt}) : super(key: key);
final int currentIndex;
final List tabInt;
@override
StackWidgetState createState() => StackWidgetState();
}
class StackWidgetState extends State {
final List _children = [
Page1(
title: "Page1",
),
Page2(
title: "Page2",
),
Page3(
title: "Page3",
),
Page4(
title: "Page4",
),
];
int _currentIndex = 0;
List _tabInt;
@override
void initState() {
// TODO: implement initState
super.initState();
_tabInt = widget.tabInt == null ? [0] : widget.tabInt;
}
@override
Widget build(BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width,
child: _stack(),
);
}
void changeStack(int currentIndex, List tabInt) {
setState(() {});
_currentIndex = currentIndex;
_tabInt = tabInt;
}
Stack _stack() {
return Stack(
children: <Widget>[
_child(0),
_child(1),
_child(2),
_child(3),
],
);
}
//Page的显示和隐藏
_child(int _index) {
return Offstage(
offstage: !(_currentIndex == _index),
child: _tabInt.contains(_index) ? _children[_index] : Container(),
);
}
}
BotNavBarWidget + StackWidget -> Scaffold
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
![](https://i-blog.csdnimg.cn/blog_migrate/4f9748583e36168b79346d0213529a3a.jpeg)
最后
今天关于面试的分享就到这里,还是那句话,有些东西你不仅要懂,而且要能够很好地表达出来,能够让面试官认可你的理解,例如Handler机制,这个是面试必问之题。有些晦涩的点,或许它只活在面试当中,实际工作当中你压根不会用到它,但是你要知道它是什么东西。
最后在这里小编分享一份自己收录整理上述技术体系图相关的几十套腾讯、头条、阿里、美团等公司2021年的面试题,把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,这里以图片的形式给大家展示一部分。
还有 高级架构技术进阶脑图、Android开发面试专题资料,高级进阶架构资料 帮助大家学习提升进阶,也节省大家在网上搜索资料的时间来学习,也可以分享给身边好友一起学习。
【算法合集】
【延伸Android必备知识点】
【Android部分高级架构视频学习资源】
**Android精讲视频领取学习后更加是如虎添翼!**进军BATJ大厂等(备战)!现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水,赶快领取吧!
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
[外链图片转存中…(img-S182aJI6-1712615047305)]
【Android部分高级架构视频学习资源】
**Android精讲视频领取学习后更加是如虎添翼!**进军BATJ大厂等(备战)!现在都说互联网寒冬,其实无非就是你上错了车,且穿的少(技能),要是你上对车,自身技术能力够强,公司换掉的代价大,怎么可能会被裁掉,都是淘汰末端的业务Curd而已!现如今市场上初级程序员泛滥,这套教程针对Android开发工程师1-6年的人员、正处于瓶颈期,想要年后突破自己涨薪的,进阶Android中高级、架构师对你更是如鱼得水,赶快领取吧!
《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!