Comments (12)
这算是Windows下开发Android使用DataBinding的常见问题了吧。因为Windows默认使用ANSI编码,简体中文的Windows下即GBK,所以需要加一个环境变量JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF-8
来指定Javac默认的编码。
关于JAVA_TOOL_OPTIONS环境变量
所以不需要全用@string
这种方式来替代硬编码,Windows用户一样可以开心地玩耍DataBinding!
@guuguo @blackbbc @StephenGiant
from tucao.
在Databinding中,我使用了类似这样的绑定:
(取自activity_search.xml)
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text='@{"共:" + viewModel.totalCount + "个相关结果"}'
android:textColor="@color/secondary_text"
android:textSize="12sp"
android:visibility="@{viewModel.totalCountVisibility}"
tools:text="共:274个相关结果" />
注意到android:text
这一行,我使用了中文。这在Unix系统下是可以编译通过的,然而在Windows下是无法编译通过的,详见:http://blog.csdn.net/yangheng362/article/details/70186866
from tucao.
谢谢,已经成功跑起来了,希望作者能把中文改成@string方式,方便我们windows用户
from tucao.
我试了下 所有的硬编码写法都不行,只能@string搞
from tucao.
我试过了你的环境变量方式 现在报的是另一个错 我还是把中文替换成string了 毕竟博主用到中文混搭接口数据的地方没几个 改起来也不是很大工作量
@DerekDick
from tucao.
@DerekDick 怎么配置这个环境变量呢?
from tucao.
@StephenGiant 知道怎么配置环境变量么?
from tucao.
@weiweiForAndroid 配置环境变量的方法是通用的,这个百度一下吧
from tucao.
@DerekDick 配置好了,运行的时候提示 Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
from tucao.
@weiweiForAndroid 这说明你环境变量配置成功了,忽略就行了
from tucao.
@DerekDick 好的 ,多谢。
from tucao.
JAVA_TOOL_OPTIONS
环境变量 俩个= 啥意思
from tucao.
Related Issues (20)
- 有遇到这个问题吗?编译报错org.jetbrains.kotlin.kapt3.diagnostic.KaptError: Error while annotation processing HOT 2
- 封面图的缩放(scaleType)有问题 HOT 3
- 问一下1.1.3下载视频需要什么系统模块。 HOT 2
- pull到1.5.1了后,运行报错,卸载原来的在运行还是报错。。。 HOT 3
- gsyVideoPlayer报错 HOT 2
- git clone --recursive -j8 https://github.com/blackbbc/Tucao.git出现问题 HOT 1
- MalformedByteSequenceException: 3 字节的 UTF-8 序列的字节 3 无效。 HOT 1
- 视频源是不是都失效了 HOT 1
- 留言板拉到有图时闪退 HOT 2
- gsyVideoPlayer 没有运行不起来 HOT 1
- 为什么提示找不到.so文件呢? HOT 3
- 【在线等】不兼容的类型: NonExistentClass无法转换为Annotation HOT 1
- bug HOT 1
- 1.1.6的问题
- 1.1.7BUG
- 库不兼容,资源还找不到
- 华为荣耀
- 原本以为不更新了,结果发现是开发者没放打包编译
- 退回首页
- 播放每个视频都会从视频页面跳回到上一个界面
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tucao.