我正在尝试为我正在开发的应用程序构建一个应用程序内语言切换器,但我已经尝试了 Stackoverflow 上几乎所有可用的方法。我还尝试了这里的官方指南https://developer.android.com/guide/topics/resources/app-languages#api-implementation
似乎什么都不起作用。这是 GitHub 上的代码https://github.com/bauripalash/Pankti-Android
这是我要更改语言的设置屏幕
fun Context.findActivity() : Activity? = when(this){
is Activity -> this
is ContextWrapper -> baseContext.findActivity()
else -> null
}
fun changeLanguage( context: Context , language: String ){
context.findActivity()?.runOnUiThread {
val appLocale = LocaleListCompat.forLanguageTags(language)
AppCompatDelegate.setApplicationLocales(appLocale)
//context.findActivity()?.recreate()
}
//context.findActivity()?.recreate()
}
Run Code Online (Sandbox Code Playgroud)
这是主要活动
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags("bn"))
AppCompatDelegate.getApplicationLocales()[0]?.let { Log.i("MainView" , it.displayLanguage) }
setContent {
PanktiMobTheme {
// A surface container using the 'background' color from the …Run Code Online (Sandbox Code Playgroud) 我在我的Ubuntu 17.04 32bit上使用bazel编译了Tensorflow,我用pip安装了结果.whl.但是当我尝试导入tensorflow时,我收到了这个错误
palash@ash:~$ python
Python 3.6.0 |Anaconda custom (32-bit)| (default, Dec 23 2016, 12:22:10)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
F tensorflow/core/platform/cpu_feature_guard.cc:35] The TensorFlow library was compiled to use SSE instructions, but these aren't available on your machine.
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)
我的bazel版本:
palash@ash:~$ bazel version
Build label: 0.4.5- (@non-git)
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri May 19 01:31:26 2017 (1495157486)
Build timestamp: 1495157486
Build timestamp …Run Code Online (Sandbox Code Playgroud) 我在Ubuntu 17.04 32bit上从源代码构建TensorFlow
导入张量流时收到此消息
palash @ ash:〜$ python
Python 3.6.0 |Anaconda 4.3.1 (32-bit)| (default, Dec 23 2016, 12:22:10)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/home/palash/anaconda3/lib/python3.6/imp.py", line 242, in load_module …Run Code Online (Sandbox Code Playgroud)