Java @列表中的类型转换器<;SomeObject>;在房间中字符串Android gson.toJson(List<;SomeObject>;)
错误: java.lang.IllegalArgumentException:class android.widget.SeekBar声明了多个名为mMinHeight的JSON字段 我的打字机Java @列表中的类型转换器<;SomeObject>;在房间中字符串Android gson.toJson(List<;SomeObject>;),java,android,json,Java,Android,Json,错误: java.lang.IllegalArgumentException:class android.widget.SeekBar声明了多个名为mMinHeight的JSON字段 我的打字机 public class ObjectConverter { private static Gson gson= new Gson(); @TypeConverter public static List<DynamicItem> fromString(Strin
public class ObjectConverter {
private static Gson gson= new Gson();
@TypeConverter
public static List<DynamicItem> fromString(String s){
if (s == null) {
return Collections.emptyList();
}
Type listType = new TypeToken<List<DynamicItem>>() {}.getType();
return gson.fromJson(s, listType);
}
@TypeConverter
public static String fromObject(List<DynamicItem> someObjects) {
//Error in the following line
return gson.toJson(someObjects,new TypeToken<List<DynamicItem>>() {}.getType());
}
}
添加数据
@Override
protected Void doInBackground(Void... voids) {
Calendar calendar = Calendar.getInstance();
String time = new SimpleDateFormat("HH:mm:ss").format(calendar.getTime());
String date = new SimpleDateFormat("dd-MM-yyyy").format(calendar.getTime());
busItem.setProxyObj(busItemList);
allTypes.setType("BUS_N");
allTypes.setTimeStamp(date + time);
allTypes.setBusItem(busItem);
allTypes.setTag(stag);
//adding to database
DBClient.getInstance(getApplicationContext()).getNotesDB()
.notesDao()
.insertAllTypes(allTypes);
return null;
}
DynamicItem
public class DynamicItem {
CustomEditText customEditText;
ImageView imageUri;
AudioItem audioItem;
String header;
String htmlEditText;
//Getters and Setters
}
我正在尝试在数据库中保存dynamicItems列表。该关系是(所有类型和业务项)(所有类型和简单)之间的一种关系。
return gson.toJson(someObjects)我已经试过了return gson.toJson(someObjects)我已经试过了
@Override
protected Void doInBackground(Void... voids) {
Calendar calendar = Calendar.getInstance();
String time = new SimpleDateFormat("HH:mm:ss").format(calendar.getTime());
String date = new SimpleDateFormat("dd-MM-yyyy").format(calendar.getTime());
busItem.setProxyObj(busItemList);
allTypes.setType("BUS_N");
allTypes.setTimeStamp(date + time);
allTypes.setBusItem(busItem);
allTypes.setTag(stag);
//adding to database
DBClient.getInstance(getApplicationContext()).getNotesDB()
.notesDao()
.insertAllTypes(allTypes);
return null;
}
public class DynamicItem {
CustomEditText customEditText;
ImageView imageUri;
AudioItem audioItem;
String header;
String htmlEditText;
//Getters and Setters
}