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

网站登录页面模板下载做网站背景

网站登录页面模板下载,做网站背景,免费自助建站平台系统,网站系统模版要使用RecyclerView显示天气预报的内容 先在grandle里添加recyclerView的引用 implementation androidx.recyclerview:recyclerview:1.3.1创建一个RecyclerView控件#xff1a;在布局文件中#xff0c;添加一个RecyclerView控件#xff0c;用于显示天气预报的列表。 这是一…要使用RecyclerView显示天气预报的内容 先在grandle里添加recyclerView的引用 implementation androidx.recyclerview:recyclerview:1.3.1创建一个RecyclerView控件在布局文件中添加一个RecyclerView控件用于显示天气预报的列表。 这是一个包含三个TextView的LinearLayout布局用于显示天气相关的数据。每个TextView都有一个唯一的id可用于在代码中找到和操作它们。 TextView的id为weatherData用于显示天气数据。 TextView的id为weatherDescription用于显示天气描述。 TextView的id为weatherTemperature用于显示天气温度。 LinearLayout的属性设置如下 android:layout_width和android:layout_height分别设置为match_parent和wrap_content使得布局宽度填充父容器高度根据内容自适应。 android:layout_marginLeft和android:layout_marginRight设置为10dp给左右两侧的边距留出10dp的空间。这样可以让布局与父容器的边缘有一个间隔。 每个TextView的属性设置如下 android:layout_width和android:layout_height都设置为wrap_content使得TextView的大小根据内容自适应。 android:layout_weight设置为1表示每个TextView在水平方向上平均分配可用的空间。 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_marginLeft10dpandroid:layout_marginRight10dpTextViewandroid:idid/weatherDataandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_weight1/TextViewandroid:idid/weatherDescriptionandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_weight1/TextViewandroid:idid/weatherTemperatureandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:layout_weight1//LinearLayout创建RecyclerView的适配器创建一个继承自RecyclerView.Adapter的适配器类用于将数据绑定到RecyclerView的子项上。 package com.example.myweather.openWeatherMapimport android.annotation.SuppressLint import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView import androidx.recyclerview.widget.RecyclerView import com.example.myweather.R import java.text.SimpleDateFormat import java.util.*class ForecastAdapter(private val forecastList: ListForecastCell) :RecyclerView.AdapterForecastAdapter.ViewHolder() {inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {val weatherData: TextView view.findViewById(R.id.weatherData)val weatherDescription: TextView view.findViewById(R.id.weatherDescription)val weatherTemperature: TextView view.findViewById(R.id.weatherTemperature)}override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {val view LayoutInflater.from(parent.context).inflate(R.layout.weather_item, parent, false)return ViewHolder(view)}SuppressLint(SetTextI18n)override fun onBindViewHolder(holder: ViewHolder, position: Int) {val kelvins 273.15val simpleDateFormat SimpleDateFormat(MM-dd HH:mm, Locale.ENGLISH)val forecastCell forecastList[position]holder.weatherData.text simpleDateFormat.format(forecastCell.dt*1000L)holder.weatherDescription.text forecastCell.weather.first().descriptionholder.weatherTemperature.text ${forecastCell.main.maxTemperature.minus(kelvins).toInt()}/ ${forecastCell.main.minTemperature.minus(kelvins).toInt()}}override fun getItemCount() forecastList.size }设置RecyclerView的布局管理器和适配器 private lateinit var forecastRecyclerView: RecyclerViewoverride fun onCreate(savedInstanceState: Bundle?) {//...forecastRecyclerView findViewById(R.id.forecastRecyclerView)forecastRecyclerView.layoutManager LinearLayoutManager(this)//... }private fun updateForecastList(forecastResponse: ForecastResponse) {val adapter ForecastAdapter(forecastResponse.forecastCellList!!)forecastRecyclerView.adapter adapter}在上面的代码中forecastCellList是包含天气预报数据的List集合。 提供数据并更新适配器在您的Activity或Fragment中提供天气预报数据并通知适配器更新数据。 当eventbus收到ForecastReponseEvent后会调用updateForecastList()去更新ForecastRecyclerView的adapter。 private fun updateForecastList(forecastResponse: ForecastResponse) {val adapter ForecastAdapter(forecastResponse.forecastCellList!!)forecastRecyclerView.adapter adapter}
http://www.pierceye.com/news/823146/

相关文章:

  • 温州网站推广驭明电脑网站模版
  • 高端定制网站开发需要多少钱秦皇岛优化网站排名
  • 有网站源码怎么搭建网站南京网站制作设计公司
  • 做网站学什么专业建个什么网站赚钱
  • 衡阳手机网站设计世界上有几个空间站
  • 推荐个做淘宝主图视频的网站苍南最好的网站建设公司
  • 山东中迅网站建设wordpress固定链接翻页404
  • 网站 改版农业网站建设方案 ppt
  • 网关高性能 网站建设设计制作长方体形状的包装纸盒视频
  • 如何做游戏推广网站廊坊百度推广公司地址
  • 国产做爰网站wordpress wrapper
  • 专业论坛网站开发开发长沙网站建设+个人
  • 河南便宜网站建设费用wordpress 记录访问ip
  • 汽车网站建设代理加盟深圳网络制作公司
  • 国外的旅游网站做的如何织梦网站根目录在哪里
  • 网站建设建站在线建站专业网站建设机构
  • 西安市城乡建设网官方网站衡水移动网站建设报价
  • 禅城区企业网站建设微信公众号网页版入口
  • 网站开发概述多城市二手车网站源码
  • 网站建设的内容策略本人做静态网站开发
  • 网站建设到运营赚钱网站主体负责人邮箱
  • 国外有在线做设计方案的网站吗网站地址免费
  • 做谷歌网站使用什么统计代码吗公司流程建设的意义
  • 网站广告收入如何缴文化事业建设费东莞人才市场招聘信息2023
  • 各大网站网址目录云服务器是什么意思
  • 免费作文网站张家港做网站排名
  • 具有营销价值好的网站找网站建设需要问什么软件
  • 免费好用的网页制作软件网站建设优化开发公司
  • 跟我一起做网站pdf电驴建设网站公开教学视频
  • 广州网站制作商怎样查看网站的权重