【发布时间】:2016-02-25 15:50:14
【问题描述】:
我正在尝试以一种自动将“:)”之类的内容替换为对应的表情符号的方式来实现表情符号。而且我不确定该怎么做,我找到了一张表情符号 UTF 代码表,但我不确定我应该如何以编程方式将它们放入 EditText :/
inputField=(EditText)temp.findViewById(R.id.inputField);
inputField.addTextChangedListener(new TextWatcher() {
boolean justChanged=false;
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(justChanged) {
justChanged=false;
return;
}
Log.d(s.toString(), s.toString());
if(s.toString().contains(":)")) {
justChanged=true;
inputField.setText(s.toString().replace(":)", "UTF CODE HERE?"));
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
【问题讨论】:
-
如果您在此处列出的当前方法不起作用,请解释它的错误之处。
-
并不是说它“不起作用”,我只是不知道如何将表情符号代码放入字符串变量中:/ 我需要一个示例,因为只需将其粘贴在那里即可纯文本格式的确切代码