<stylename="Theme.Demo1"parent="Theme.MaterialComponents.DayNight.DarkActionBar"><!-- Primary brand color. --><item name="colorPrimary">@color/purple_500</item>//状态栏的背景色,优先级小于android:statusBarColor<item name="colorPrimaryVariant">@color/purple_700</item><item name="colorOnPrimary">@color/white</item><!-- Secondary brand color. --><item name="colorSecondary">@color/teal_200</item><item name="colorSecondaryVariant">@color/teal_700</item><item name="colorOnSecondary">@color/black</item><!-- Status bar color. 状态栏标题,在31上面可显示--><item name="android:statusBarColor">?attr/colorPrimaryVariant</item><!-- Customize your theme here. --></style>``````xml<stylename="Theme.Demo1.NoActionBar"><item name="windowActionBar">false</item><item name="windowNoTitle">true</item></style>
//特定xml页面privatevar _binding:FragmentTransformBinding?=null// This property is only valid between onCreateView and// onDestroyView.private val binding get()= _binding!!override fun onCreateView(inflater:LayoutInflater,container:ViewGroup?,savedInstanceState:Bundle?):View{//获取viewmodel,TransformViewModel.ktval transformViewModel =ViewModelProvider(this).get(TransformViewModel::class.java)//获取xml视图_binding =FragmentTransformBinding.inflate(inflater, container,false)//获取xml文件的根视图,并返回val root:View= binding.root//获取控件idval recyclerView = binding.recyclerviewTransformval adapter =TransformAdapter()recyclerView.adapter = adapter//监听数据回调transformViewModel.texts.observe(viewLifecycleOwner){adapter.submitList(it)}return root}``````java
override fun onCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)//获取布局文件binding =ActivityMainBinding.inflate(layoutInflater)//向activity设置布局文件,需要为根布局setContentView(binding.root)//设置actionbarsetSupportActionBar(binding.appBarMain.toolbar)binding.appBarMain.fab?.setOnClickListener { view ->Snackbar.make(view,"Replace with your own action",Snackbar.LENGTH_LONG).setAction("Action",null).show()}//获取导航navfragmentval navHostFragment =(supportFragmentManager.findFragmentById(R.id.nav_host_fragment_content_main) as NavHostFragment?)!!//获取nav导航控制器val navController = navHostFragment.navControllerbinding.navView?.let {//设置全部的fragmentappBarConfiguration =AppBarConfiguration(setOf(R.id.nav_transform,R.id.nav_reflow,R.id.nav_slideshow,R.id.nav_settings),binding.drawerLayout)setupActionBarWithNavController(navController, appBarConfiguration)it.setupWithNavController(navController)}binding.appBarMain.contentMain.bottomNavView?.let {//设置tabbar对应的3个页面appBarConfiguration =AppBarConfiguration(setOf(R.id.nav_transform,R.id.nav_reflow,R.id.nav_slideshow))setupActionBarWithNavController(navController, appBarConfiguration)it.setupWithNavController(navController)}}
根据Github Trendings的统计,今日(2024-10-29统计)共有10个项目上榜。根据开发语言中项目的数量,汇总情况如下: 开发语言项目数量Python项目10TypeScript项目1gpt4free存储库:强大语言模型的集合 创建周期:300 天开发语言:Python协议类型:GNU General Public License v3…
在 Kubernetes 中,LoadBalancer 类型的 Service 允许用户轻松地将应用暴露给外部流量。它自动创建一个云负载均衡器并分配一个外部 IP 地址。然而,在某些情况下,LoadBalancer 类型的 Service 可能未能成功分配 IP 地址,导致外部无…