| | |
| | | import androidx.lifecycle.ViewModelProvider |
| | | import androidx.recyclerview.widget.LinearLayoutManager |
| | | import androidx.recyclerview.widget.RecyclerView |
| | | import com.bumptech.glide.Glide |
| | | import com.example.firstapp.R |
| | | import com.example.firstapp.activity.PickupActivity |
| | | import com.example.firstapp.adapter.ExpressAdapter |
| | |
| | | |
| | | //通过 ViewModelProvider 获取 HomeViewModel 的实例,以便在视图中使用。 |
| | | homeViewModel = ViewModelProvider(this).get(HomeViewModel::class.java) |
| | | |
| | | // 加载广告图片 |
| | | //loadAdvertisements() |
| | | //调用这个方法来设置 RecyclerView用于设置 RecyclerView 的布局和适配器。 |
| | | setupRecyclerViews() |
| | | setupTabSwitching() |
| | |
| | | super.onDestroyView() |
| | | _binding = null |
| | | } |
| | | |
| | | private fun loadAdvertisements() { |
| | | // 使用 Glide 加载网络图片 |
| | | Glide.with(this) |
| | | .load("http://192.168.1.235:9999/advertisement/up.png") |
| | | .into(binding.adBanner) |
| | | |
| | | Glide.with(this) |
| | | .load("http://192.168.1.235:9999/advertisement/down.png") |
| | | .into(binding.bottomAdBanner) |
| | | } |
| | | } |