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

湖南地税局官网站水利建设基金自己怎么制作logo图标

湖南地税局官网站水利建设基金,自己怎么制作logo图标,学校网站建设分工,优门设 网站高版本的gradle不再支持 kotlin-android-extensions插件#xff0c;因此view的绑定方式也有所改变。 1.启用视图绑定 android {...viewBinding {enabled true}} 如果想在生成绑定类时忽略某个布局文件#xff0c;请将 tools:viewBindingIgnoretrue 属性添加到…高版本的gradle不再支持 kotlin-android-extensions插件因此view的绑定方式也有所改变。 1.启用视图绑定 android {...viewBinding {enabled true}} 如果想在生成绑定类时忽略某个布局文件请将 tools:viewBindingIgnoretrue 属性添加到相应布局文件的根视图中 LinearLayout...tools:viewBindingIgnoretrue ... /LinearLayout 2.在 Activity 中使用视图绑定 如需设置绑定类的实例以供 Activity 使用请在 Activity 的 onCreate() 方法中执行以下步骤 调用生成的绑定类中包含的静态 inflate() 方法。此操作会创建该绑定类的实例以供 Activity 使用。通过调用 getRoot() 方法或使用 Kotlin 属性语法获取对根视图的引用。将根视图传递到 setContentView()使其成为屏幕上的活动视图。 private lateinit var binding: ResultProfileBindingoverride fun onCreate(savedInstanceState: Bundle) {super.onCreate(savedInstanceState)binding ResultProfileBinding.inflate(layoutInflater)val view binding.rootsetContentView(view)} 3.在 Fragment中使用视图绑定 如需设置绑定类的实例以供 Fragment 使用请在 Fragment 的 onCreateView() 方法中执行以下步骤 调用生成的绑定类中包含的静态 inflate() 方法。此操作会创建该绑定类的实例以供 Fragment 使用。通过调用 getRoot() 方法或使用 Kotlin 属性语法获取对根视图的引用。从 onCreateView() 方法返回根视图使其成为屏幕上的活动视图。 private var _binding: ResultProfileBinding? nullprivate val binding get() _binding!!override fun onCreateView(inflater: LayoutInflater,container: ViewGroup?,savedInstanceState: Bundle?): View? {_binding ResultProfileBinding.inflate(inflater, container, false)return binding.root}override fun onDestroyView() {super.onDestroyView()_binding null} 4.自定义Dialog中使用 public class MyDialog extends Dialog {protected View mView;protected DialogBottomBinding mBinding;public MyDialog(NonNull Context context, StyleRes int themeResId) {super(context, themeResId);//原来的写法// mView View.inflate(getContext(), getLayoutId(), null);//使用ViewBinding的写法mBinding DialogBottomBinding.inflate(getLayoutInflater());mView mBinding.getRoot();setContentView(mView);} } 5.在自定义View中使用 // 自定义view public class MyLinearLayout extends LinearLayout {public MyLinearLayout(Context context) {this(context, null);}public MyLinearLayout(Context context, Nullable AttributeSet attrs) {this(context, attrs, 0);}public MyLinearLayout(Context context, Nullable AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);// 正常添加布局亲测有效ViewMyLayoutBinding binding LibPlateformLayoutBinding.inflate(LayoutInflater.from(getContext()), this, true);// 方法二// val root View.inflate(context, R.layout.widget_core, this)// binding WidgetCoreBinding.bind(root)// 针对根标签为mergeViewMyLayoutMergeBinding binding ViewMyLayoutMergeBinding.inflate(LayoutInflater.from(getContext()), this);}} 6.在RecyclerView的Adapter中使用 class StudentAdapter(private val context: Context,private val list: ListAddressInfo) : RecyclerView.AdapterItemViewHolder() {override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {val studentBinding ItemAddressBinding.inflate(LayoutInflater.from(context), parent, false)return ItemViewHolder(studentBinding)}SuppressLint(SetTextI18n)override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {holder.itemBinding.tvName.text 姓名 list[position].name}override fun getItemCount(): Int {return list.size}inner class ItemViewHolder(var itemBinding: ItemAddressBinding) : RecyclerView.ViewHolder(itemBinding.root) } 以上是各场景使用viewBinding的方式基本可以满足大家的开发需求如有其他场景的可以在评论区留言讨论。
http://www.hkea.cn/news/14397487/

相关文章:

  • 成都装修网站制作指数是什么
  • 网站模板建站教程视频教程网站维护哪些
  • 网站内容衡水做企业网站的公司
  • 微站官网专业软文平台
  • 梨园网站建设公司门户网站建设特点
  • 企业如何建自己的网站wordpress 网站访问认证页面
  • 建设工程标准在线网站广东建设工程协会网站
  • 做电容元器件的网站有哪些网站开发项目需求
  • 网站开发 flex全国最大的外发加工网
  • 有高级感的公司名字seo网站seo
  • 建企业网站需要哪些资料百度大数据查询
  • 如何做发卡网站小红书搜索优化
  • 卖主机网站哪个网站适合 做红本抵押
  • 青岛李沧区城乡建设局网站四川城乡与建设厅网站
  • 网站建设丩金手指排名壹陆淘宝的网站建设情况
  • 公司建设网站费用吗东莞海边网站建设工作室
  • 网站搭建周期微信平台微商城
  • 网站开发及服务合同模板苏州市建设工程建设中心网站
  • 重庆建网站诚选快忻科技悉心网站做目录中
  • 网站平台怎么做的好网页制作模板秋季
  • 东莞建网站公司品牌flash可以做网站
  • 专业做网站app的公司哪家好一个企业官网多个营销型网站
  • 想把自己做的网站放到网上企业信息公示系统全国官网
  • 第一推是谁做的网站为什么建设旅游网站
  • 网站建设费的会计分录邢台市信都区
  • 如何做好电商网站平面设计免费行情软件app合集
  • 大型移动网站开发wordpress出现的常见问题
  • 网站后台上传表格wordpress 流量管理系统
  • 建设网站怎么提需求wordpress页面立体效果
  • 建个网站的流程一个用vue做的网站