Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

只有通过getApplicationContext().getString()才能转换成功 #18

Open
YonStone opened this issue Mar 2, 2020 · 9 comments
Open

Comments

@YonStone
Copy link

YonStone commented Mar 2, 2020

tvValue.setText(getString(R.string.tv3_value)); //翻译不成功
tvValue2.setText(getApplicationContext().getString(R.string.tv3_value)); //翻译成功

根据文档接入,但是直接赋值翻译不了

@MichaelJokAr
Copy link
Owner

报什么错

@YonStone
Copy link
Author

YonStone commented Mar 2, 2020

没有报错,就是必须要在getString()前加上getApplicationContext()才能正常翻译。但是demo下载下来跑又不需要加上

@MichaelJokAr
Copy link
Owner

你是在activity里的么

@YonStone
Copy link
Author

YonStone commented Mar 2, 2020

是的,我怕自己误操作,把几个activity和资源文件,包括MultiLanguagesApp都是直接复制到新建的项目中。不过没有加入MyService和MyIntentService,(我看源代码 这部分代码不执行也能翻译成功,是这里的原因吗)

@MichaelJokAr
Copy link
Owner

我在mainActivity里也没有用getApplicationContext(),你的activity的attachBaseContext有自己重写么

@YonStone
Copy link
Author

YonStone commented Mar 3, 2020

有用过getApplicationContext()的啊,上面那段代码是直接复制过去的,attachBaseContext是在BaseActivity里重写

@MichaelJokAr
Copy link
Owner

image

@MichaelJokAr
Copy link
Owner

@YonStone 麻烦试试v0.0.8版本

@qiudanyao
Copy link

有用过getApplicationContext()的啊,上面那段代码是直接复制过去的,attachBaseContext是在BaseActivity里重写

请问解决了嘛?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants