我的应用程序中有两种语言.values/strings.xml和values-ru/strings.xml当我以编程方式更改语言时,所有字符串都会进行转换,但活动标题不会更改.我在所有活动中使用
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String languageToLoad = prefs.getString("prefLanguage","en");
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
Run Code Online (Sandbox Code Playgroud)
当我选择语言时,重新加载活动或应用程序.
有没有人有GCM java第三方服务器示例的链接?我无法理解如何实现它.在http://developer.android.com/google/gcm/server.html中,我找不到完整的示例.
我想读HealthDataTypes.Scope我必须在创建时设置哪个GoogleApiClient?
.addScope(new Scope(????))
Run Code Online (Sandbox Code Playgroud) 我在服务器中序列化数据:
Gson gson = new Gson();
Map<String, List<?>> resultMap = BackendUpdateManager.getInstance()
.getUpdates(timeHolder, shopIdInt, buyerIdInt);
gson.toJson(resultMap);
Run Code Online (Sandbox Code Playgroud)
并反序列化:
Gson gson = new Gson();
Map<String, List<?>> resultMap = gson.fromJson(json,
new TypeToken<Map<String, List<?>>>() {
}.getType());
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用以下项目时Map:
List<ProductCategory> productCategoryList = (List<ProductCategory>)updateMap.get(key);
for(ProductCategory productCategory : productCategoryList) {
}
Run Code Online (Sandbox Code Playgroud)
我得到错误:
造成的:
java.lang.ClassCastException:com.google.gson.internal.LinkedTreeMap不能强制转换为com.example.model.entity.ProductCategory
如何修复此错误或以其他方式创建 Mapwith List<different classes>?
我尝试使用 getter 和 setter 创建类,其中包含List不同类的 s 而不是Map<String, List<?>>并将其用于序列化和反序列化。但我正在寻找更好的方法。
我可以使用以下代码在模型中获取url(活动存储)
Rails.application.routes.url_helpers.rails_blob_path(picture_of_car, only_path: true)
但是我需要获取调整后的瓦里安网址
picture_of_car.variant(resize: "300x300").processed
例如此代码
Rails.application.routes.url_helpers.rails_blob_path(picture_of_car.variant(resize: "300x300").processed, only_path: true)
扔
NoMethodError (undefined method `signed_id' for #< ActiveStorage::Variant:0x0000000004ea6498 >):
Run Code Online (Sandbox Code Playgroud)