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

郑州哪有做网站的高端网站建设与制作

郑州哪有做网站的,高端网站建设与制作,网站风格怎么写,2手房产App网站开发kotlin - 2个Fragment实现左右显示#xff0c;左边列表#xff0c;右边详情#xff0c;平板横、竖屏切换(要使用平板测试)平板横屏#xff1a;左右fragment实现分屏效果#xff0c;平板竖屏#xff1a;只显示左边的fragment#xff0c;点击才显示右边fragment屏幕旋转左边列表右边详情平板横、竖屏切换(要使用平板测试)平板横屏左右fragment实现分屏效果平板竖屏只显示左边的fragment点击才显示右边fragment屏幕旋转会销毁重新创建执行onCreate方法。在AndroidManifest.xml配置android:configChangesscreenSize|smallestScreenSize|screenLayout|orientation|keyboardHidden|navigation属性,只调用onConfigurationChanged方法fragment的add方法如果新打开一个activity该fragment只回调onStop()方法没有调用onDestroy()方法。如果popBackStack或者finish会回调onStop()和onDestroy()方法replace方法旧的fragment执行onDestroy()方法然后新建一个fragment执行onViewCreated()方法。 package com.example.androidkotlindemo2.pad.leftrightimport android.content.Intent import android.content.res.Configuration import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import com.example.androidkotlindemo2.R import com.example.androidkotlindemo2.utils.LogUtils/*** Author : wn* Email : maoning20080809163.com* Date : 2025/8/30 21:41* Description : (要使用平板测试)平板横屏左右fragment实现分屏效果平板竖屏只显示左边的fragment点击才显示右边fragment* 屏幕旋转会销毁重新创建执行onCreate方法。* 在AndroidManifest.xml配置android:configChangesscreenSize|smallestScreenSize|screenLayout|orientation|keyboardHidden|navigation属性,只调用onConfigurationChanged方法* fragment的* add方法* 如果新打开一个activity该fragment只回调onStop()方法没有调用onDestroy()方法。* 如果popBackStack或者finish会回调onStop()和onDestroy()方法* replace旧的fragment执行onDestroy()方法然后新建一个fragment执行onViewCreated()方法。*/ class LRFragmentActivity : AppCompatActivity() {//平板横屏private var isLandscape: Boolean falseoverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.lr_fragment_main)LogUtils.d(LeftRightMainActivity onCreate);// 初始化显示列表Fragmentif (savedInstanceState null) {supportFragmentManager.beginTransaction().replace(R.id.fragment_list_container, LRListFragment()).commit()}checkOrientation()}//检查横、竖屏private fun checkOrientation() {val orientation resources.configuration.orientationisLandscape orientation Configuration.ORIENTATION_LANDSCAPE}fun setOnItemClick(position: Int, lrItem: LRItem) {if(position 3){if(isLandscape){//平板横屏左右显示fragmentshowItemDetailReplace(lrItem)} else {//平板竖屏使用新的Activity显示startRightActivity(lrItem)}} else if(position 6){//只适配平板横屏效果showItemDetailAdd(lrItem)} else {showItemNewActivity(lrItem)}}//竖屏打开新的Activityfun startRightActivity(lrItem: LRItem){val intent Intent(this, LRRightActivity::class.java)intent.putExtra(lr_item, lrItem)startActivity(intent)}//使用replace方法fun showItemDetailReplace(lrItem: LRItem) {val detailFragment LRDetailReplaceFragment.newInstance(lrItem)supportFragmentManager.beginTransaction().replace(R.id.fragment_detail_container, detailFragment).commit()}//使用add方法, 只回调onStop方法不回调onDestroy方法fun showItemDetailAdd(LRItem: LRItem) {val detailNewFragment LRDetailAddFragment.newInstance(LRItem)supportFragmentManager.beginTransaction().add(R.id.fragment_detail_container, detailNewFragment).addToBackStack(detail_new_fragment) // 添加这行才能popBackStack回退.commit()}//屏幕旋转移除fragmentfun removeDetailFragment(){val detailFragment supportFragmentManager.findFragmentById(R.id.fragment_detail_container)if(detailFragment ! null){supportFragmentManager.beginTransaction().remove(detailFragment).commit()}}//使用add方法, 只回调onStop方法不回调onDestroy方法fun showItemNewActivity(LRItem: LRItem) {startActivity(Intent(this, LRNewActivity::class.java))}override fun onConfigurationChanged(newConfig: Configuration) {super.onConfigurationChanged(newConfig)LogUtils.i(LeftRightMainActivity onConfigurationChanged);checkOrientation()removeDetailFragment()}override fun onStop() {super.onStop()LogUtils.d(LeftRightMainActivity onDestroy)}override fun onDestroy() {super.onDestroy()LogUtils.d(LeftRightMainActivity onDestroy)}override fun onNewIntent(intent: Intent?) {super.onNewIntent(intent)LogUtils.i(LeftRightMainActivity onNewIntent)}} package com.example.androidkotlindemo2.pad.leftrightimport android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.example.androidkotlindemo2.R import com.example.androidkotlindemo2.utils.LogUtils/*** Author : wn* Email : maoning20080809163.com* Date : 2025/8/30 21:41* Description :*/ class LRListFragment : Fragment(){private lateinit var recyclerView: RecyclerViewprivate lateinit var adapter: LRAdapterprivate var LRItemList mutableListOfLRItem()override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,savedInstanceState: Bundle?): View? {return inflater.inflate(R.layout.lr_fragment_item_list, container, false)}override fun onViewCreated(view: View, savedInstanceState: Bundle?) {super.onViewCreated(view, savedInstanceState)setupRecyclerView(view)loadItems()}private fun setupRecyclerView(view: View) {recyclerView view.findViewById(R.id.recycler_view)adapter LRAdapter(LRItemList, object : LROnItemClickInter{override fun setOnItemClick(position: Int, lrItem: LRItem) {// 通知Activity显示详情(activity as? LRFragmentActivity)?.setOnItemClick(position,lrItem)}override fun setOnLongClickListener(position: Int, lrItem: LRItem) {LogUtils.i(长按${position})}})recyclerView.layoutManager LinearLayoutManager(requireContext())recyclerView.adapter adapterrecyclerView.addItemDecoration(DividerItemDecoration(requireContext(), LinearLayoutManager.VERTICAL))}private fun loadItems() {for(i in 1 .. 20){LRItemList.add(LRItem(i, 项目${i}, 这是第${i}个项目的详细描述))}adapter.notifyDataSetChanged()} } package com.example.androidkotlindemo2.pad.leftrightimport android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Button import android.widget.TextView import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import com.example.androidkotlindemo2.MyApp import com.example.androidkotlindemo2.R import com.example.androidkotlindemo2.utils.LogUtils/*** Author : wn* Email : maoning20080809163.com* Date : 2025/8/30 21:45* Description : 新的详情使用fragment的add方法调用只会调用onStop()*/ class LRDetailAddFragment : Fragment() {companion object {private const val ARG_ITEM itemfun newInstance(LRItem: LRItem): LRDetailAddFragment {val fragment LRDetailAddFragment()val args Bundle().apply {putParcelable(ARG_ITEM, LRItem)}fragment.arguments argsreturn fragment}}override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,savedInstanceState: Bundle?): View? {return inflater.inflate(R.layout.lr_fragment_item_detail, container, false)}override fun onViewCreated(view: View, savedInstanceState: Bundle?) {super.onViewCreated(view, savedInstanceState)LogUtils.w(LRDetailAddFragment onViewCreated ----------------------------)LogUtils.w(LRDetailAddFragment onViewCreated() ${this})arguments?.getParcelableLRItem(ARG_ITEM)?.let { item -displayItemDetails(view, item)}view.findViewByIdButton(R.id.lr_item_details_back).visibility View.VISIBLE//返回view.findViewByIdButton(R.id.lr_item_details_back).setOnClickListener {LogUtils.i(LRDetailNewFragment返回)requireActivity().supportFragmentManager.popBackStack()}view.findViewByIdButton(R.id.lr_item_details_finish).visibility View.VISIBLE//关闭 -view.findViewByIdButton(R.id.lr_item_details_finish).setOnClickListener {LogUtils.i(LRDetailNewFragment关闭)requireActivity().finish()}}override fun onStart() {super.onStart()LogUtils.w(LRDetailAddFragment onStart() ${this})}override fun onResume() {super.onResume()LogUtils.w(LRDetailAddFragment onResume() ${this})}override fun onPause() {super.onPause()LogUtils.w(LRDetailAddFragment onPause() ${this})}override fun onStop() {super.onStop()LogUtils.w(LRDetailAddFragment onStop() ${this})}override fun onDestroy() {super.onDestroy()LogUtils.w(LRDetailAddFragment onDestroy() ${this})}private fun displayItemDetails(view: View, LRItem: LRItem) {view.findViewByIdTextView(R.id.title_text_view).text LRItem.titleview.findViewByIdTextView(R.id.description_text_view).text 新页面 LRItem.descriptionview.findViewByIdTextView(R.id.description_text_view).setTextColor(ContextCompat.getColor(MyApp.myApp,R.color.blue))view.findViewByIdTextView(R.id.description_text_view).setTextSize(30f)} } package com.example.androidkotlindemo2.pad.leftrightimport android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Button import android.widget.TextView import androidx.fragment.app.Fragment import com.example.androidkotlindemo2.R import com.example.androidkotlindemo2.utils.LogUtils/*** Author : wn* Email : maoning20080809163.com* Date : 2025/8/30 21:45* Description : 使用replace方法会调用onStop()和onDestroy()方法*/ class LRDetailReplaceFragment : Fragment() {companion object {private const val ARG_ITEM itemfun newInstance(LRItem: LRItem): LRDetailReplaceFragment {val fragment LRDetailReplaceFragment()val args Bundle().apply {putParcelable(ARG_ITEM, LRItem)}fragment.arguments argsreturn fragment}}override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,savedInstanceState: Bundle?): View? {return inflater.inflate(R.layout.lr_fragment_item_detail, container, false)}override fun onViewCreated(view: View, savedInstanceState: Bundle?) {super.onViewCreated(view, savedInstanceState)LogUtils.i(LRDetailReplaceFragment onViewCreated ----------------------------)LogUtils.d(LRDetailReplaceFragment onViewCreated() ${this})arguments?.getParcelableLRItem(ARG_ITEM)?.let { item -displayItemDetails(view, item)}//返回view.findViewByIdButton(R.id.lr_item_details_back).visibility View.GONEview.findViewByIdButton(R.id.lr_item_details_finish).visibility View.GONE}override fun onStart() {super.onStart()LogUtils.d(LRDetailReplaceFragment onStart() ${this})}override fun onResume() {super.onResume()LogUtils.d(LRDetailReplaceFragment onResume() ${this})}override fun onPause() {super.onPause()LogUtils.d(LRDetailReplaceFragment onPause() ${this})}override fun onStop() {super.onStop()LogUtils.d(LRDetailReplaceFragment onStop() ${this})}override fun onDestroy() {super.onDestroy()LogUtils.d(LRDetailReplaceFragment onDestroy() ${this})}private fun displayItemDetails(view: View, LRItem: LRItem) {view.findViewByIdTextView(R.id.title_text_view).text LRItem.titleview.findViewByIdTextView(R.id.description_text_view).text LRItem.description} } package com.example.androidkotlindemo2.pad.leftrightimport android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView import androidx.cardview.widget.CardView import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import com.example.androidkotlindemo2.MyApp import com.example.androidkotlindemo2.R/*** Author : wn* Email : maoning20080809163.com* Date : 2025/8/30 21:42* Description :*/ class LRAdapter(private val itemList: ListLRItem,private val listener: LROnItemClickInter ) : RecyclerView.AdapterLRAdapter.ItemViewHolder() {var selectedPosition -1inner class ItemViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {val titleTextView: TextView itemView.findViewById(R.id.title_text_view)val container: LinearLayout itemView.findViewById(R.id.item_container)}override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder {val view LayoutInflater.from(parent.context).inflate(R.layout.lr_fragment_item, parent, false)return ItemViewHolder(view)}override fun onBindViewHolder(holder: ItemViewHolder, position: Int) {val lrItem itemList[position]holder.titleTextView.text lrItem.titleholder.container.setOnClickListener {listener.setOnItemClick(position, lrItem)selectedPosition positionnotifyDataSetChanged()}holder.container.setOnLongClickListener {listener.setOnLongClickListener(position, lrItem)true}if(selectedPosition position){holder.container.setBackgroundColor(ContextCompat.getColor(MyApp.myApp, R.color.lr_item_selected_bg))} else {holder.container.setBackgroundColor(ContextCompat.getColor(MyApp.myApp, R.color.lr_item_default_bg))}}override fun getItemCount(): Int itemList.size } package com.example.androidkotlindemo2.pad.leftrightimport android.os.Bundle import android.widget.Button import androidx.appcompat.app.AppCompatActivity import com.example.androidkotlindemo2.R import com.example.androidkotlindemo2.utils.LogUtils/*** Author : wn* Email : maoning20080809163.com* Date : 2025/9/6 13:04* Description : 打开新的页面*/ class LRNewActivity : AppCompatActivity(){override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.lr_activity_new)LogUtils.e(LRNewActivity onViewCreated ----------------------------)findViewByIdButton(R.id.lr_activity_new_close).setOnClickListener {finish()}}override fun onCreateDescription(): CharSequence? {return super.onCreateDescription()}override fun onDestroy() {super.onDestroy()LogUtils.e(LRNewActivity onDestroy ----------------------------)} } package com.example.androidkotlindemo2.pad.leftright/*** Author : wn* Email : maoning20080809163.com* Date : 2025/9/6 9:46* Description :*/ interface LROnItemClickInter {//点击fun setOnItemClick(position: Int, lrItem: LRItem)//长按fun setOnLongClickListener(position: Int, lrItem: LRItem)} package com.example.androidkotlindemo2.pad.leftrightimport android.os.Bundle import android.widget.Button import androidx.appcompat.app.AppCompatActivity import com.example.androidkotlindemo2.R import com.example.androidkotlindemo2.utils.LogUtils/*** Author : wn* Email : maoning20080809163.com* Date : 2025/9/6 13:04* Description : 在Activity中显示右边的fragment*/ class LRRightActivity : AppCompatActivity(){override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.lr_activity_right)val lrItem intent.getParcelableExtraLRItem(lr_item) as LRItemif (savedInstanceState null) {supportFragmentManager.beginTransaction().replace(R.id.fragment_right_container, LRDetailReplaceFragment.newInstance(lrItem)).commit()}}} package com.example.androidkotlindemo2.pad.leftrightimport android.os.Parcel import android.os.Parcelable /*** Author : wn* Email : maoning20080809163.com* Date : 2025/8/30 21:41* Description :*/ data class LRItem(val id: Int,val title: String,val description: String,val imageUrl: String? null ) : Parcelable {constructor(parcel: Parcel) : this(parcel.readInt(),parcel.readString() ?: ,parcel.readString() ?: ,parcel.readString())override fun writeToParcel(parcel: Parcel, flags: Int) {parcel.writeInt(id)parcel.writeString(title)parcel.writeString(description)parcel.writeString(imageUrl)}override fun describeContents(): Int {return 0}companion object CREATOR : Parcelable.CreatorLRItem {override fun createFromParcel(parcel: Parcel): LRItem {return LRItem(parcel)}override fun newArray(size: Int): ArrayLRItem? {return arrayOfNulls(size)}} } lr_fragment_main.xml布局 ?xml version1.0 encodingutf-8? LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationhorizontalandroid:weightSum2FrameLayoutandroid:idid/fragment_list_containerandroid:layout_width300dpandroid:layout_heightmatch_parent/TextViewandroid:layout_width1dpandroid:layout_heightmatch_parentandroid:backgroundcolor/blue/FrameLayoutandroid:idid/fragment_detail_containerandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent//LinearLayout lr_fragment_item_list.xml布局 ?xml version1.0 encodingutf-8? androidx.recyclerview.widget.RecyclerViewxmlns:androidhttp://schemas.android.com/apk/res/androidandroid:idid/recycler_viewandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:padding8dp / lr_fragment_item_detail.xml布局 ?xml version1.0 encodingutf-8? ScrollView xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:backgroundcolor/gray_e5e5e5android:padding16dpLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationverticalandroidx.appcompat.widget.AppCompatButtonandroid:idid/lr_item_details_finishandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textAllCapsfalseandroid:textSize30spandroid:textColorcolor/greenandroid:text关闭finish/androidx.appcompat.widget.AppCompatButtonandroid:idid/lr_item_details_backandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textAllCapsfalseandroid:textSize30spandroid:textColorcolor/greenandroid:text返回/TextViewandroid:idid/title_text_viewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:textSize24spandroid:textStyleboldandroid:layout_marginBottom16dp /TextViewandroid:idid/description_text_viewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:textSize16sp /TextViewandroid:idid/description_tipandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:textColorcolor/redandroid:text1-3 使用 fragment 的 replace \n 4-6使用 fragment 的add() \n 其他使用打开activityandroid:textSize26sp //LinearLayout/ScrollView lr_fragment_item.xml布局 ?xml version1.0 encodingutf-8? LinearLayoutxmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoandroid:idid/item_containerandroid:backgrounddrawable/lr_click_item_bgandroid:clickabletrueandroid:focusabletrueandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_margin4dpLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:padding16dpandroid:orientationverticalTextViewandroid:idid/title_text_viewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:textSize18spandroid:textStylebold //LinearLayout/LinearLayout lr_activity_new.xml布局 ?xml version1.0 encodingutf-8? ScrollView xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:backgroundcolor/gray_e5e5e5android:padding16dpLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationverticalandroidx.appcompat.widget.AppCompatButtonandroid:idid/lr_activity_new_closeandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textAllCapsfalseandroid:text关闭/TextViewandroid:idid/title_text_viewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:textSize24spandroid:textStyleboldandroid:text新的Activityandroid:layout_marginBottom16dp /TextViewandroid:idid/description_text_viewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:textSize16sp //LinearLayout/ScrollView lr_activity_right.xml布局 ?xml version1.0 encodingutf-8?LinearLayoutxmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:backgroundcolor/gray_e5e5e5android:orientationverticalFrameLayoutandroid:idid/fragment_right_containerandroid:layout_widthmatch_parentandroid:layout_heightmatch_parent/ /LinearLayout drawable lr_click_item_bg.xml ?xml version1.0 encodingutf-8? selector xmlns:androidhttp://schemas.android.com/apk/res/androiditem android:drawablecolor/lr_item_selected_bg android:state_selectedtrue/item android:drawablecolor/lr_item_selected_bg android:state_pressedtrue/item android:drawablecolor/lr_item_default_bg/ /selector color namelr_item_default_bg#FFFFFF/color color namelr_item_selected_bg#FF00FF/color activity android:name.pad.leftright.LRFragmentActivity android:configChangesscreenSize|smallestScreenSize|screenLayout|orientation|keyboardHidden|navigation/ activity android:name.pad.leftright.LRNewActivity/ activity android:name.pad.leftright.LRRightActivity/
http://www.zqtcl.cn/news/831066/

相关文章:

  • 法律网站建设价格做视频周边的网站
  • 京东物流网站地方门户网站源码下载
  • 重庆建设工程信息网站企业宣传片制作公司光年映画
  • 哪家做网站好 成都ktv网络推广方案
  • 网站开发的软件支持哈尔滨最新消息
  • jsp淘宝客网站有限公司怎么注册
  • 香奈儿电子商务网站建设策划书怎样进行网络营销吸引顾客
  • 昆山网站建设费用我们公司想做网络推广
  • 网站建设一般要多少钱网站开发主要步骤
  • 商用图片的网站网络文化经营许可证查询
  • c 高性能网站开发弄一个公司网站需要多少钱
  • 建设部网站招标投标文件网页设计专业公司
  • 使用iis6搭建网站wordpress调用搜索功能
  • 装配式建筑网站生活家装饰
  • 怎样做软件网站建设百度网站认证官网
  • phpcms网站什么网站都能进的浏览器
  • 建设配资网站有要求吗网站建设不一定当地
  • 永兴网站开发智慧门店管理服务平台
  • 网站建设前的市场分析李炎辉网站建设教程
  • 乱起封神是那个网站开发的?广州市建设注册中心网站首页
  • 网站开发配置网络广告的投放技巧
  • wordpress 漫画网站安徽省建设厅八大员报名网站
  • 音乐网站排名建设部证书查询网站
  • 长沙建站挺找有为太极wordpress eshop 教程
  • 郑州平台类网站网站开发常见面试题
  • 城乡建设网站职业查询系统做网站设计的需要什么材料
  • ui做的好看的论坛网站加工制造网
  • 南庄网站开发厦门建设局网站城市建设
  • 常州网站建设效果重庆招聘网
  • 做视频网站需要多大的带宽公众号怎么开通直播功能