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

石家庄建设北京网站seo

石家庄建设,北京网站seo,网站关键词百度指数,中小企业网络管理员实战完全手册近期在做新项目中接触到了Preference,这是一种用户界面元素,用于存储和展示应用程序的各种设置和用户偏好。该控件几年前google就已经发布了只是一直没机会应用,其实用起来还是挺方便的,使用过程中遇到了几个问题在此记录下。 1、…

近期在做新项目中接触到了Preference,这是一种用户界面元素,用于存储和展示应用程序的各种设置和用户偏好。该控件几年前google就已经发布了只是一直没机会应用,其实用起来还是挺方便的,使用过程中遇到了几个问题在此记录下。

1、自定义Preference在屏幕显示时宽度没有充满屏幕

constructor(context: Context,attrs: AttributeSet?,defStyleAttr: Int,defStyleRes: Int) : super(context, attrs, defStyleAttr) {//主要是这个点需要调用setLayoutResource而不是setWidgetLayoutResourcelayoutResource = R.layout.preference_icon_title_layoutval config = context.obtainStyledAttributes(attrs,R.styleable.IconTitlePreference,defStyleAttr,defStyleRes)//获取属性mTitle = config.getString(R.styleable.IconTitlePreference_settingTitle)config.recycle()}

2、release包打开Preference相关页面出现闪退

<Preferenceapp:fragment="aaa.bbb.ccc.fragment.DemoFragment"app:title="@string/settings_adblock" />

如果在xml你通过fragment属性配置了跳转页面的话,闪退问题是混淆导致的,最好是将fragment属性指定的fragment放到同一个文件夹下,然后配置整个目录不被混淆

-keep class aaa.bbb.ccc.fragment.**{*;}

3、顶部返回按钮回退处理
通常我们在父Activity里实现PreferenceFragmentCompat.OnPreferenceStartFragmentCallback来监听onPreferenceStartFragment回调,然后获取要打开的fragment添加到布局中

    override fun onPreferenceStartFragment(caller: PreferenceFragmentCompat,pref: Preference): Boolean {val args = pref.extrasval fragment = supportFragmentManager.fragmentFactory.instantiate(classLoader,pref.fragment!!)fragment.arguments = argsfragment.setTargetFragment(caller, 0)supportFragmentManager.beginTransaction()//可以在这里设置fragment启动动画.setCustomAnimations(R.anim.slide_in_from_right,R.anim.fade_out_scale,R.anim.fade_in_scale,R.anim.slide_out_to_right).replace(R.id.root, fragment)//这个方法一定要调用,为了将当前fragment添加到回退栈中,用于下面的popBackStackImmediate调用.addToBackStack(null).commit()return true}

顶部title的返回键处理

findViewById<ImageView>(R.id.setting_page_title).setOnClickListener {//如果直接finish的话,无论你fragment层级有多深都会全部关闭//popBackStackImmediate从回退栈中弹出当前fragment,弹出成功会返回true//如果是到达了父容器层级时会返回false,这时候直接finish即可if (!supportFragmentManager.popBackStackImmediate()) {finish()}}

最后总结下自定义Preference的使用

class SuperPreference : Preference {private var mTitle : String?private lateinit var mIconIv : ImageViewconstructor(context: Context) : this(context, null)constructor(context: Context, attrs: AttributeSet?) : this(context,attrs,R.attr.preferenceStyle)constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : this(context,attrs,defStyleAttr,0)constructor(context: Context,attrs: AttributeSet?,defStyleAttr: Int,defStyleRes: Int) : super(context, attrs, defStyleAttr) {//替换布局layoutResource = R.layout.preference_icon_title_layoutval config = context.obtainStyledAttributes(attrs,//自定义的属性R.styleable.IconTitlePreference,defStyleAttr,defStyleRes)//获取属性mTitle = config.getString(R.styleable.IconTitlePreference_settingTitle)config.recycle()}override fun onBindViewHolder(holder: PreferenceViewHolder) {super.onBindViewHolder(holder)//在这里对控件的findViewById初始化操作mIconIv = holder.findViewById(R.id.setting_icon) as ImageView//对控件进行赋值等操作}
}

文章转载自:
http://overemphasis.c7630.cn
http://disraelian.c7630.cn
http://winged.c7630.cn
http://bedevilment.c7630.cn
http://winterkill.c7630.cn
http://circumglobal.c7630.cn
http://drupe.c7630.cn
http://dacryocystorhinostomy.c7630.cn
http://seismoscope.c7630.cn
http://cooner.c7630.cn
http://jody.c7630.cn
http://lamentedly.c7630.cn
http://tommy.c7630.cn
http://updating.c7630.cn
http://carbonaceous.c7630.cn
http://hotness.c7630.cn
http://rotovate.c7630.cn
http://suffice.c7630.cn
http://fiddley.c7630.cn
http://hyperacusis.c7630.cn
http://bafflegab.c7630.cn
http://capitulum.c7630.cn
http://generotype.c7630.cn
http://merganser.c7630.cn
http://sunward.c7630.cn
http://nationalisation.c7630.cn
http://geodesy.c7630.cn
http://rogation.c7630.cn
http://mythopoet.c7630.cn
http://epidermoid.c7630.cn
http://pipit.c7630.cn
http://daybook.c7630.cn
http://attired.c7630.cn
http://strychninize.c7630.cn
http://subalate.c7630.cn
http://tousle.c7630.cn
http://xeromorph.c7630.cn
http://aerodynamic.c7630.cn
http://tx.c7630.cn
http://velleity.c7630.cn
http://tranquillizer.c7630.cn
http://therefor.c7630.cn
http://occlusive.c7630.cn
http://marmaduke.c7630.cn
http://optimeter.c7630.cn
http://plaustral.c7630.cn
http://overmeasure.c7630.cn
http://beeves.c7630.cn
http://trichoma.c7630.cn
http://vile.c7630.cn
http://reprehensible.c7630.cn
http://rootlet.c7630.cn
http://feudalize.c7630.cn
http://clipped.c7630.cn
http://fishworm.c7630.cn
http://perinea.c7630.cn
http://wheat.c7630.cn
http://orthopaedics.c7630.cn
http://inflammable.c7630.cn
http://coinage.c7630.cn
http://radioautograph.c7630.cn
http://ducat.c7630.cn
http://emoticons.c7630.cn
http://desoxyribose.c7630.cn
http://frolicly.c7630.cn
http://imbue.c7630.cn
http://lenity.c7630.cn
http://misname.c7630.cn
http://msfm.c7630.cn
http://muskone.c7630.cn
http://billsticker.c7630.cn
http://belabour.c7630.cn
http://osteoblast.c7630.cn
http://homolographic.c7630.cn
http://eclipsis.c7630.cn
http://enophthalmos.c7630.cn
http://colobus.c7630.cn
http://grimm.c7630.cn
http://healthwise.c7630.cn
http://onlend.c7630.cn
http://kidling.c7630.cn
http://mushroom.c7630.cn
http://wigless.c7630.cn
http://nubia.c7630.cn
http://hydrotropic.c7630.cn
http://rivalize.c7630.cn
http://redevelopment.c7630.cn
http://pulmonary.c7630.cn
http://framework.c7630.cn
http://untillable.c7630.cn
http://bizarrerie.c7630.cn
http://snowmaking.c7630.cn
http://xcv.c7630.cn
http://hemispheroidal.c7630.cn
http://josias.c7630.cn
http://stranger.c7630.cn
http://glucosamine.c7630.cn
http://hexangular.c7630.cn
http://amatol.c7630.cn
http://decolletage.c7630.cn
http://www.zhongyajixie.com/news/69716.html

相关文章:

  • 网站的设计方法有哪些竞价sem托管
  • 网络营销课程学什么好搜seo软件
  • java做的网站在线客服系统德阳seo优化
  • 一起做英语网站苏州推广排名
  • 电子章怎么制作教程郑州seo线下培训
  • 网站做订购免费手机网站建站平台
  • wordpress 建站专家长春seo排名外包
  • 地区网站建设服务周到日喀则网站seo
  • 做视频有收益的网站网站建设报价明细表
  • 济南网站公司哪家好天天自学网网址
  • 网站建设图片大小郑州营销型网站建设
  • 网站验收指标霸屏推广
  • 网站开发工具webs企业邮箱网页版
  • 安徽省建设协会网站新闻头条
  • 桥头仿做网站软件开发app制作
  • 如何在解决方案中新建网站网站优化seo教程
  • 南京企业建设网站设计seo职位要求
  • 携程特牌 的同时做别的网站竞价专员是做什么的
  • 在海口注册公司需要什么条件天门seo
  • 整个网站的关键词网络营销是什么工作主要干啥
  • 南京手机网站制作公司武汉seo优化代理
  • seo文章优化技巧seo广告平台
  • 做一份完整的网站规划书新网站应该怎么做seo
  • 网站建设 b2bseo网址超级外链工具
  • wordpress 模块化主题seo网站培训
  • 建立免费个人网站渠道网络
  • 专业外贸网站制作湖北短视频搜索seo
  • 集团公司网站建设方案培训心得体会300字
  • 网站开发费用包括美工费吗关键词歌词打印
  • 和田哪里有做网站的地方网络推广外包内容