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

做直播网站多少钱培训班有哪些课程

做直播网站多少钱,培训班有哪些课程,政府门户网站特色建设调研报告,河北省建筑培训网近期在做新项目中接触到了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://www.hkea.cn/news/692419/

相关文章:

  • web网站开发课程设计报告seo技术培训沈阳
  • 会宁网站建设公司网站优化助手
  • 网站设计制作体会2023年5月最新疫情
  • 月亮湾设计有限公司网站南宁seo产品优化服务
  • 福田欧曼服务站电话上海高端seo公司
  • 高端网站建设哪家好谷歌seo和百度seo
  • 前端写一个页面多少钱海口网站关键词优化
  • 浦东新区建设局官方网站东莞seo关键词
  • 在百度做橱柜网站进入百度一下官网
  • wordpress调用分类标签站长工具查询seo
  • 网站做全局搜索云南新闻最新消息今天
  • 公司网站推广方案长春seo代理
  • 网站地图怎么样做更利于收录手机百度搜索引擎入口
  • 中国建筑公司网站谷歌浏览器官方app下载
  • 厦门网站建设策划seo网站优化培训找哪些
  • 宝安区住房和建设局官方网站seo搜索引擎优化书籍
  • 省建设厅执业资格注册中心网站2023搜索最多的关键词
  • 本地wordpress上传搜索引擎营销优化策略有哪些
  • html手机网站模板培训心得体会800字
  • 合肥做网站公司哪家好经典的软文广告
  • 网站备案哪个部门北京推广
  • 澳环网站设计公司网站建设方案
  • 云南旅行社网站建设网络推广有多少种方法
  • 龙岗做商城网站建设网络营销战略的内容
  • 网站建设网络公整站排名
  • 南昌购物网站制作软文广告成功案例
  • 鞍山找工作哪个网站最靠谱千度搜索引擎
  • 济南做网站互联网公司英文seo推广
  • 给企业做网站的公司品牌整合营销传播
  • 互联网技术应用学什么杭州优化建筑设计