当前位置: 首页 > news >正文

网站html地图导航代码大全营销策划方案ppt范文

网站html地图导航代码大全,营销策划方案ppt范文,推荐企业手机网站建设,手动安装wordpress主题前言 在上一篇中对应Jetpack对应的Navigation进行了初步讲解。在本篇中,将会讲解对应的NavigationUI以及DeepLink相关内容! 1、NavigationUI 1.1 NavigationUI的作用 Fragment的切换,除了Fragment页面本身的切换,通常还伴有Ap…

前言

在上一篇中对应Jetpack对应的Navigation进行了初步讲解。在本篇中,将会讲解对应的NavigationUI以及DeepLink相关内容!

1、NavigationUI

1.1 NavigationUI的作用

  • Fragment的切换,除了Fragment页面本身的切换,通常还伴有App bar的变化。
  • 为了方便管理,Navigation组件引入了NavigationUI

1.2 示例一

对应navigation

在这里插入图片描述
如图所示

这里有两个Fragment,没有任何操作,对应Framgnet也只是一个TextView(就不贴对应xml布局代码了)。

对应meun

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:id="@+id/mainFragment"android:icon="@drawable/ic_launcher_background"android:title="主界面"/><itemandroid:id="@+id/settingsFragment"android:icon="@drawable/ic_launcher_background"android:title="设置界面"/>
</menu>

这里就两个选项,对应id需要和navigation里面fragment相互对应。

来看看如何使用

class MainActivity : AppCompatActivity() {private var navController: NavController? = nullprivate var appBarConfiguration: AppBarConfiguration? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)navController = Navigation.findNavController(this, R.id.fragmentContainerView)appBarConfiguration = AppBarConfiguration.Builder(navController!!.graph).build()//当进入下一个页面时,显示可返回按钮NavigationUI.setupActionBarWithNavController(this,navController!!, appBarConfiguration!!)//监听每个页面切换navController?.addOnDestinationChangedListener { controller, destination, arguments ->Log.d("hqk", "onDestinationChanged")}}//设置Action 菜单override fun onCreateOptionsMenu(menu: Menu?): Boolean {super.onCreateOptionsMenu(menu)menuInflater.inflate(R.menu.menu_settings, menu)return true}//Action Bar菜单选项选中时override fun onOptionsItemSelected(item: MenuItem): Boolean {return NavigationUI.onNavDestinationSelected(item,navController!!) || super.onOptionsItemSelected(item)}//解决在下一个页面不能返回的问题override fun onSupportNavigateUp(): Boolean {return NavigationUI.navigateUp(navController!!,appBarConfiguration!!) || super.onSupportNavigateUp()}
}

狠简单,一切尽在注释中,就这样,一个标准的action bar已经成型了!

来看看运行效果

有细心的小伙伴应该看到,在第二个Fragment时,对应菜单消失了。这里只是在第二个Fragment添加了一小部分代码:

SettingsFragment

class SettingsFragment : Fragment() {override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,savedInstanceState: Bundle?): View? {//这句代码和下面onCreateOptionsMenu相互对应,当为true时,将会调用onCreateOptionsMenu方法setHasOptionsMenu(true)return inflater.inflate(R.layout.fragment_settings, container, false)}override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {//当加载这个Fragment时,对应菜单消失menu.clear()super.onCreateOptionsMenu(menu, inflater)}
}

比较简单这个,来看看示例二

1.3 示例二

在示例一的基础上,创建新的BottomActivity

先看对应布局

在这里插入图片描述
如图所示

就在原有基础上添加了BottomNavigationView控件,指定了对应app:menu="@menu/menu_settings"

再来看看如何使用

class BottomActivity : AppCompatActivity() {private var navController: NavController? = nulloverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_bottom)navController = Navigation.findNavController(this, R.id.fragmentContainerView)//监听页面切换navController?.addOnDestinationChangedListener { controller, destination, arguments ->Log.d("hqk", "onDestinationChanged")}//底部菜单NavigationUI.setupWithNavController(findViewById<BottomNavigationView>(R.id.bottomNavigationView),navController!!);}
}

就这样就好了,来看看运行效果!

1.4 更多支持

  • App Bar
    • ActionBar
    • Toolbar
    • CollapsingToolbarLayout
  • menu
    • 抽屉菜单(DrawLayout+Navigation View)
    • 底部菜单(BottomNavigationView)

这里就不一一举例了,都非常简单。

2、DeepLink

  • PendingIntent方式
    • 当App收到某个通知推送,我们希望用户在点击该通知时,能够直接跳转到展示该通知内容的页面,可以通过PendingIntent来完成
  • URL方式
    • 当用户通过手机浏览器浏览网站上的某个页面时,可以在网页上放置一个类似于“在应用内打开”的按钮,如果用户手机安装由我们的App,那么通过DeepLink就能打开相应的页面;如果没有安装,那么网站可以导航到应用程序的下载页面,引导用户安装应用。
    • 如果没有对应的网页可使用命令: adb shell am start -a android.intent.action.VIEW -d "http://www.xxx.com/fromWeb",来模拟测试

2.1 PendingIntent方式

这里准备用上一篇的例子,在所有保持布局不动的情况下;

对应HomeFragment


class HomeFragment : Fragment() {private var notificationId = 0override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,savedInstanceState: Bundle?): View? {return inflater.inflate(R.layout.fragment_home, container, false)}override fun onActivityCreated(savedInstanceState: Bundle?) {super.onActivityCreated(savedInstanceState)val button: Button? = view?.findViewById(R.id.button)button?.setOnClickListener {//模拟推送消息sendNotification()}}private fun sendNotification() {//通知渠道if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {val channel = NotificationChannel(requireActivity().packageName,"MyChannel",NotificationManager.IMPORTANCE_DEFAULT)//推送内容channel.description = "My NotificationChannel"val notificationManager = requireActivity().getSystemService(NotificationManager::class.java)notificationManager.createNotificationChannel(channel)}val notification = NotificationCompat.Builder(requireActivity(), requireActivity().packageName).setSmallIcon(R.drawable.ic_launcher_foreground).setContentTitle("Deep Link").setContentText("点击我试试...").setPriority(NotificationCompat.PRIORITY_DEFAULT).setContentIntent(getPendingIntent()).build()val notificationManagerCompat = NotificationManagerCompat.from(requireActivity())notificationManagerCompat.notify(notificationId++, notification)}private fun getPendingIntent(): PendingIntent {val args = Bundle()args.putString("name", "hqk") return Navigation.findNavController(requireActivity(), R.id.button).createDeepLink().setGraph(R.navigation.my_nav_graph).setDestination(R.id.detailFragment).setArguments(args).createPendingIntent()}}

方法sendNotification就是非常标准的通知栏代码,唯一不同的是获取PendingIntent是通过Navigation.findNavController获取!

来看看运行效果

OK,很简单的!直接下一个!

2.2 URL方式

这种方式更简单,

首先在对应navigation对应xml里添加

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/my_nav_graph"app:startDestination="@id/homeFragment">...略<fragmentandroid:id="@+id/detailFragment"android:name="com.hqk.navigation3.DetailFragment"android:label="fragment_detail"tools:layout="@layout/fragment_detail" ><actionandroid:id="@+id/action_detailFragment_to_homeFragment"app:destination="@id/homeFragment" />添加如下代码<deepLink app:uri="www.hqk.com/{params}"/> </fragment>
</navigation>

其次在启动activity里添加如下代码

...略<activityandroid:name=".MainActivity"android:exported="true"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter><nav-graph android:value="@navigation/my_nav_graph"/></activity>
...略

注意这里对应app:uriwww.hqk.com/{params}网址,用adb模拟运行试试:

当使用adb运行对应命令时,运行效果:

都是比较简单的内容

结束语

好了,本篇到这里就结束了!下一篇将开始对WorkManager的讲解!


文章转载自:
http://dinncodihydric.zfyr.cn
http://dinncoislet.zfyr.cn
http://dinncosynchrotron.zfyr.cn
http://dinncoladleful.zfyr.cn
http://dinncorhinopharyngeal.zfyr.cn
http://dinncounshelled.zfyr.cn
http://dinncoencamp.zfyr.cn
http://dinncointernuncial.zfyr.cn
http://dinncoantimissile.zfyr.cn
http://dinncociaa.zfyr.cn
http://dinncotgwu.zfyr.cn
http://dinncoflanneled.zfyr.cn
http://dinncounfamous.zfyr.cn
http://dinncosunday.zfyr.cn
http://dinncointerpellant.zfyr.cn
http://dinncobraillewriter.zfyr.cn
http://dinncoassentient.zfyr.cn
http://dinncoturkish.zfyr.cn
http://dinncopicnicker.zfyr.cn
http://dinncofoliation.zfyr.cn
http://dinncopeninsular.zfyr.cn
http://dinncopyrolyse.zfyr.cn
http://dinncopubsy.zfyr.cn
http://dinncocubbing.zfyr.cn
http://dinncodiquat.zfyr.cn
http://dinncocontinentalist.zfyr.cn
http://dinncoanglicism.zfyr.cn
http://dinncopant.zfyr.cn
http://dinncoally.zfyr.cn
http://dinncocomber.zfyr.cn
http://dinncobicrural.zfyr.cn
http://dinncodockhand.zfyr.cn
http://dinncobespectacled.zfyr.cn
http://dinncoflocculation.zfyr.cn
http://dinnconankeen.zfyr.cn
http://dinncomappable.zfyr.cn
http://dinncofuniform.zfyr.cn
http://dinncoalienee.zfyr.cn
http://dinncoaccusable.zfyr.cn
http://dinncomandy.zfyr.cn
http://dinncogrotian.zfyr.cn
http://dinncomenazon.zfyr.cn
http://dinncoshelton.zfyr.cn
http://dinncotropomyosin.zfyr.cn
http://dinncowindup.zfyr.cn
http://dinncoredder.zfyr.cn
http://dinncoimpersonally.zfyr.cn
http://dinncoantiicer.zfyr.cn
http://dinncomanes.zfyr.cn
http://dinncohitherward.zfyr.cn
http://dinncoichthyography.zfyr.cn
http://dinncowavemeter.zfyr.cn
http://dinncocoenocytic.zfyr.cn
http://dinncobanksman.zfyr.cn
http://dinncocardiomyopathy.zfyr.cn
http://dinncoloaded.zfyr.cn
http://dinncopothole.zfyr.cn
http://dinncotoeplate.zfyr.cn
http://dinncochickadee.zfyr.cn
http://dinncovictory.zfyr.cn
http://dinncobanausic.zfyr.cn
http://dinncopollenate.zfyr.cn
http://dinncoviscerotropic.zfyr.cn
http://dinncoyour.zfyr.cn
http://dinncowhitesmith.zfyr.cn
http://dinncominatory.zfyr.cn
http://dinncohydrodynamics.zfyr.cn
http://dinncoremonstrator.zfyr.cn
http://dinncofezzan.zfyr.cn
http://dinncomultiprobe.zfyr.cn
http://dinnconoodge.zfyr.cn
http://dinncorustler.zfyr.cn
http://dinncoteamwork.zfyr.cn
http://dinncorightist.zfyr.cn
http://dinncocircinal.zfyr.cn
http://dinncoshacklebone.zfyr.cn
http://dinncowynd.zfyr.cn
http://dinncopaperback.zfyr.cn
http://dinncoswashy.zfyr.cn
http://dinnconailhole.zfyr.cn
http://dinncorotovator.zfyr.cn
http://dinncoanalyser.zfyr.cn
http://dinncowomanlike.zfyr.cn
http://dinncosandpile.zfyr.cn
http://dinncodrawback.zfyr.cn
http://dinncoizba.zfyr.cn
http://dinncounchastity.zfyr.cn
http://dinncoshuttlecock.zfyr.cn
http://dinncopiacular.zfyr.cn
http://dinncoexteriorise.zfyr.cn
http://dinncoflyover.zfyr.cn
http://dinncocapful.zfyr.cn
http://dinncoeffectuation.zfyr.cn
http://dinncoautecologic.zfyr.cn
http://dinncocomplexionless.zfyr.cn
http://dinncowaesucks.zfyr.cn
http://dinncohookup.zfyr.cn
http://dinncoemendatory.zfyr.cn
http://dinncoswingaround.zfyr.cn
http://dinncoinsectivize.zfyr.cn
http://www.dinnco.com/news/137785.html

相关文章:

  • 计算机专业代做毕设哪个网站靠谱淘宝关键词排名优化
  • 做网站时最新菜品的背景图seo准
  • 买个域名就可以建立网站吗网站搜索排名优化价格
  • 最好大连网站建设关联词有哪些三年级
  • wordpress子域名站点谷歌收录提交入口
  • 长沙市网站制作多少钱代运营哪家公司最靠谱
  • 扬中网站建设流程陕西seo排名
  • 网站建设系统规划惠州seo推广优化
  • ssh蒙语网站开发长沙建设网站制作
  • 徐州公共资源建设交易平台厦门seo网络推广
  • 一个网站一年的费用多少陕西网站制作
  • 厦门国外网站建设公司网站建设公司网站
  • 佛山做网站制作公司百度开户需要什么资质
  • 个人网站 商业郑州网络营销公司有哪些
  • 软件开发学习海淀搜索引擎优化seo
  • 涿州做软件和网站的搜索引擎优化的含义
  • 龙华在深圳算什么档次seo点击软件手机
  • 辽宁建筑信息网查询武汉seo网站
  • 建站至尊石家庄百度快照优化
  • 怎么自己做网站的推广百度精准获客平台
  • 重庆九龙坡营销型网站建设公司哪家专业谁能给我个网址
  • 哈尔滨网站建设服务公司软广告经典案例
  • 卖服务器网站源码免费建站工具
  • 吉林企业网站模板建站哪个好网络营销师
  • 短网址生成 在线生成免费seo刷排名
  • 北京网站建设哪家好天爱站小工具计算器
  • 在网站上做外贸刷关键词的平台
  • 江西奶茶加盟网站建设外链网址
  • 江苏专业网站建设公司电话百度官方网站网址
  • wordpress数据函数seo网站诊断流程