這篇文章主要講解了“Java怎么實現(xiàn)側(cè)邊欄功能”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Java怎么實現(xiàn)側(cè)邊欄功能”吧!

import 'package:flutter/material.dart';
import 'tabs/Home.dart';
import 'tabs/Category.dart';
import 'tabs/Setting.dart';
class Tabs extends StatefulWidget {
final index;
Tabs({Key key, this.index = 0}) : super(key: key);
@override
_TabsState createState() => _TabsState(this.index);
}
class _TabsState extends State<Tabs> {
int _currentIndex = 0;
_TabsState(index) {
this._currentIndex = index;
}
// 把頁面存放到數(shù)組里
List _pageList = [
HomePage(),
CategoryPage(),
SettingPage(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('首頁'),
),
body: this._pageList[this._currentIndex],
bottomNavigationBar: BottomNavigationBar(
// 默認選中第幾項
currentIndex: this._currentIndex,
// 導(dǎo)航欄點擊獲取索引值
onTap: (int index) {
setState(() {
this._currentIndex = index;
});
},
// iconSize: 30.0, //icon的大小
fixedColor: Colors.red, //選中的顏色
type: BottomNavigationBarType.fixed, //配置底部tabs可以有多個按鈕
//定義導(dǎo)航欄的圖片+名稱
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("首頁")),
BottomNavigationBarItem(
icon: Icon(Icons.category), title: Text("分類")),
BottomNavigationBarItem(
icon: Icon(Icons.settings), title: Text("設(shè)置")),
],
),
// 這里是核心代碼
drawer: Drawer(
child: Column(
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: UserAccountsDrawerHeader(
accountName: Text("任我行RQ"),
accountEmail: Text("www.1342134929@qq.com"),
currentAccountPicture: CircleAvatar(
backgroundImage: NetworkImage(
"/tupian/20230522/404.html
),
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
"/tupian/20230522/404.html
fit: BoxFit.cover,
)),
))
],
),
ListTile(
leading: CircleAvatar(
child: Icon(Icons.home),
),
title: Text("我的空間"),
onTap: () {
Navigator.of(context).pop(); //隱藏側(cè)邊欄
Navigator.pushNamed(context, '/NavBar'); //路由的跳轉(zhuǎn)
},
),
Divider(),
ListTile(
leading: CircleAvatar(
child: Icon(Icons.people),
),
title: Text("用戶中心"),
),
Divider(),
ListTile(
leading: CircleAvatar(
child: Icon(Icons.settings),
),
title: Text("設(shè)置中心"),
),
],
),
),
);
}
}感謝各位的閱讀,以上就是“Java怎么實現(xiàn)側(cè)邊欄功能”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對Java怎么實現(xiàn)側(cè)邊欄功能這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!
文章題目:Java怎么實現(xiàn)側(cè)邊欄功能-創(chuàng)新互聯(lián)
網(wǎng)頁路徑:http://chinadenli.net/article18/cddgdp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、做網(wǎng)站、網(wǎng)站設(shè)計公司、網(wǎng)站導(dǎo)航、網(wǎng)站排名、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容