From c7e1fddc1dab02a992a9c54f55b0e518cd5f973d Mon Sep 17 00:00:00 2001 From: whycq <913841844@qq.com> Date: 星期三, 05 二月 2025 13:07:32 +0800 Subject: [PATCH] # --- app/src/main/java/com/example/agvcontroller/EditeActivity.java | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/example/agvcontroller/EditeActivity.java b/app/src/main/java/com/example/agvcontroller/EditeActivity.java index 784ae80..ec0186f 100644 --- a/app/src/main/java/com/example/agvcontroller/EditeActivity.java +++ b/app/src/main/java/com/example/agvcontroller/EditeActivity.java @@ -1,6 +1,6 @@ package com.example.agvcontroller; -import android.content.Intent; +import android.annotation.SuppressLint; import android.content.SharedPreferences; import android.os.Bundle; import android.util.Log; @@ -22,12 +22,13 @@ public class EditeActivity extends AppCompatActivity { private RecyclerView recyclerView; - private List<Item> items; + private List<AGVCar> items; private EditeAdapter adapter; private SharedPreferences sharedPreferences; private AppCompatImageButton addItem; private Button confirm; + @SuppressLint("WrongViewCast") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -52,7 +53,7 @@ @Override public void onClick(View v) { - items.add(new Item("", "", 0, "", 0)); + items.add(new AGVCar("", "", 0, "", 0)); adapter.notifyDataSetChanged(); Log.d("items", items.toString()); } @@ -81,11 +82,11 @@ editor.apply(); } - private List<Item> loadItemsFromSharedPreferences() { + private List<AGVCar> loadItemsFromSharedPreferences() { Gson gson = new Gson(); String json = sharedPreferences.getString("items", null); if (json != null) { - Type type = new TypeToken<List<Item>>(){}.getType(); + Type type = new TypeToken<List<AGVCar>>(){}.getType(); return gson.fromJson(json, type); } return new ArrayList<>(); -- Gitblit v1.9.1