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

网站备案是否收费标准怎样创建网站详细步骤

网站备案是否收费标准,怎样创建网站详细步骤,hao123设为主页官网下载,网站建设的主要问题增加界面显示openweathermap返回的信息。 在activity_main.xml里增加输入框来输入城市#xff0c;在输入款旁边增加搜索按钮来进行查询。 然后原来显示helloworld的TextView用来显示结果。 1. 增加输入城市名字的EditText EditTextandroid:idid/editTextCity在输入款旁边增加搜索按钮来进行查询。 然后原来显示helloworld的TextView用来显示结果。 1. 增加输入城市名字的EditText EditTextandroid:idid/editTextCityandroid:layout_width0dpandroid:layout_heightwrap_contentandroid:hintstring/editTextCityHintapp:layout_constraintTop_toTopOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintEnd_toStartOfid/buttonSearch/增加搜索按钮 Buttonandroid:idid/buttonSearchandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentapp:layout_constraintTop_toTopOfid/editTextCityapp:layout_constraintBottom_toBottomOfid/editTextCityapp:layout_constraintStart_toEndOfid/editTextCityapp:layout_constraintEnd_toEndOfparentandroid:textstring/buttonSearchText /3. 增加显示的TextView TextViewandroid:idid/weatherResultandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textHello World!app:layout_constraintBottom_toBottomOfparentapp:layout_constraintEnd_toEndOfparentapp:layout_constraintStart_toStartOfparentapp:layout_constraintTop_toTopOfparent /使用broadcast的方式把收到的天气信息发送到界面显示。 Android的广播机制是一种用于在应用程序内和应用程序之间传递消息和事件的方式。通过广播一个应用程序可以发送消息被称为广播而其他应用程序可以接收并处理这些广播。 广播发送者Broadcast Sender应用程序或者系统组件如系统服务可以通过发送广播来通知其他应用程序或组件事件的发生。广播发送者并不需要知道接收者是谁只需要发送广播即可。广播接收者Broadcast Receiver应用程序或者组件可以通过注册广播接收器来接收特定类型的广播。广播接收者可以在AndroidManifest.xml文件中声明静态接收器也可以在代码中动态注册接收器。广播的类型Android广播可以分为普通广播和有序广播两种类型。普通广播Normal Broadcast普通广播是一种异步的广播发送方式广播发送者不需要等待接收者处理广播。这使得广播发送者能够快速地发送广播而不会受到接收者处理时间的影响。有序广播Ordered Broadcast有序广播是一种同步的广播发送方式广播发送者会按照优先级的顺序发送广播接收者依次处理广播。每个接收者处理完广播后可以选择终止广播或者将广播传递给下一个接收者。广播过滤器Broadcast Filter广播过滤器允许应用程序指定它们所感兴趣的广播类型。广播接收者可以根据广播过滤器过滤来自特定来源或具有特定操作的广播。这样可以减少不必要的广播传递提高性能。系统广播System BroadcastAndroid系统内置了一些广播用于通知应用程序和组件系统事件的发生例如设备启动、网络连接状态变化、电池低电量等。应用程序可以注册对这些系统广播感兴趣的接收者以执行相应的操作。 通过广播机制应用程序可以实现一种松耦合的通信方式让不同的组件之间进行信息传递和事件触发。这种机制使得应用程序能够更好地响应系统事件、应用程序状态的变化并且可以与其他应用程序之间进行交互。 4.注册一个自定义的广播 将广播接收器的类名替换为您自己的接收器类名并使用 intent-filter 添加您自定义的广播 action。 ?xml version1.0 encodingutf-8? manifest xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsuses-permission android:nameandroid.permission.INTERNET /application !-- ... --activity !-- ... --/activityreceiverandroid:name.WeatherResponseReceiverandroid:exportedfalseintent-filteraction android:namecom.example.MyWeather.ACTION_WEATHER_DATA//intent-filter/receiver/application/manifest5.在RetrofitClient类中发送广播 在发送自定义广播时您需要使用 sendBroadcast() 方法并指定广播的 action。 private fun handleWeatherData(context: Context, weatherData: WeatherResponse?) {if (weatherData ! null) {val intent Intent(com.example.MyWeather.ACTION_WEATHER_DATA)intent.putExtra(cityName, weatherData.name)intent.putExtra(temperature, weatherData.main?.temp)intent.putExtra(maxTemperature, weatherData.main?.temp_max)intent.putExtra(minTemperature, weatherData.main?.temp_min)val weatherStringArray arrayListOfString()for(weather in weatherData.weather) {weatherStringArray main:${weather.main},description:${weather.description}}intent.putStringArrayListExtra(weather, weatherStringArray)context.sendBroadcast(intent)printWeatherData(weatherData)}}6.创建一个用来接受广播的类并重写onReceive函数。 class WeatherResponseReceiver : BroadcastReceiver() {private var textView: TextView? nullfun setTextView(textView: TextView) {this.textView textView}override fun onReceive(context: Context?, intent: Intent?) {if(intent?.action com.example.MyWeather.ACTION_WEATHER_DATA) {val kelvins 273.15val cityName intent.getStringExtra(cityName)val temperature intent.getFloatExtra(temperature, 0.0F) - kelvinsval maxTemperature intent.getFloatExtra(maxTemperature, 0.0F) - kelvinsval minTemperature intent.getFloatExtra(minTemperature, 0.0F) - kelvinsval weather intent.getStringArrayListExtra(weather)val decimalFormat DecimalFormat(#.#)SuppressLint(SetTextI18n)textView?.text $cityName\n${decimalFormat.format(temperature)}\n${decimalFormat.format(maxTemperature)}\n${decimalFormat.format(minTemperature)}\n$weather}} }为了能让收到的广播消息能够显示在TextView中我把TextView的指针传递给了接收广播的类。 class MainActivity : AppCompatActivity() {private lateinit var weatherResponseReceiver: WeatherResponseReceiveroverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)weatherResponseReceiver WeatherResponseReceiver()weatherResponseReceiver.setTextView(findViewByIdTextView(R.id.weatherResult))val intentFilter IntentFilter(com.example.MyWeather.ACTION_WEATHER_DATA)registerReceiver(weatherResponseReceiver, intentFilter)findViewByIdButton(R.id.buttonSearch).setOnClickListener { searchCityNameWeather(it) }}override fun onDestroy() {super.onDestroy()unregisterReceiver(weatherResponseReceiver)}private fun searchCityNameWeather(view: View) {val cityName findViewByIdEditText(R.id.editTextCity).text.toString().trim()RetrofitClient.getWeatherByCityName(view.context, cityName)} }7.最后的测试结果
http://www.huolong8.cn/news/27320/

相关文章:

  • 鄞州区建网站外包租房网站开发需求文档
  • 网站开发会什么软件帮做ppt网站
  • 建设摩托车公司官方网站电子商务网站开发方式
  • 河北网站建设联系电话wordpress lampp建站
  • 做设计的地图网站有哪些济南网络平台设计
  • 网站的建设目标是什么意思wordpress首页文章缩略图
  • 山东省住房城乡建设厅网站首页耒阳市古雍网站建设店
  • 做网站手机适配需要加价吗成都水高新区建设局官方网站
  • 天津网站优化网站搭建工作室加盟
  • 科技公司企业网站源码天津企业建站系统
  • 常平建设局网站wordpress只备份数据
  • 小游戏网站开发者杭州建设网址
  • 屏山县龙华镇中心村建设招标网站微信公众号制作网站有哪些
  • 山西网站建设服务好我要做自媒体要怎么开始
  • html5官方网站开发流程哪个网站设计好
  • 做庭院的网站银川seo优化
  • 一个人可以建设网站吗公司网站建设的视频教程
  • 做生意网站泰安网络犯罪案件
  • 什么网站可以做海报网站排名网站优化
  • 验证网站所有权用手机做空间建网站
  • 深圳骏域网站建设专家88WordPress 先登录
  • 动易网站系统黄骅市天气预报最新
  • 产品设计培训机构排名空调seo是什么意思
  • 有什么做糕点的视频网站建设部人事考试网站官网
  • 网站建站大约多少钱海外网站建设推广最好的
  • 好的深圳网站页面设计wordpress网址改坏了
  • 建立网站的英语外贸平台有哪些是免费的
  • 钢材料 网站建设 中企动力国外代理ip地址和端口
  • 口碑好的徐州网站建设华为网站开发流程
  • sql网站源码建筑网片产品资料