cloudroam
2025-03-24 380d70f2f1cd03b314fa6de64df30eab914956ba
app/src/main/java/com/example/firstapp/ui/home/HomeFragment.kt
@@ -14,6 +14,7 @@
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
@@ -50,7 +51,8 @@
        //通过 ViewModelProvider 获取 HomeViewModel 的实例,以便在视图中使用。
        homeViewModel = ViewModelProvider(this).get(HomeViewModel::class.java)
        // 加载广告图片
        //loadAdvertisements()
        //调用这个方法来设置 RecyclerView用于设置 RecyclerView 的布局和适配器。
        setupRecyclerViews()
        setupTabSwitching()
@@ -210,4 +212,15 @@
        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)
    }
}