我正在尝试使用EditText实现一个活动,该活动用表情符号替换一些关键字(我的代码在最后).
除了一个细节之外,代码工作得很完美.如果我输入EditText".sa." 它被img1取代,但如果我要撤消它,我需要在图像消失之前单击4次删除(对于关键字中的每个字符一次).
这是我第一次使用Spannables并且不知道如何修复它.你能帮助我吗?
public class MytestActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
EditText et = (EditText) findViewById(R.id.editText1);
et.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
getSmiledText(MytestActivity.this, s);
Log.e("",s.toString());
}
});
}
private static final HashMap<String, Integer> emoticons = new HashMap<String, Integer>();
static {
emoticons.put(".sa.", R.drawable.img1);
emoticons.put(".sb.", R.drawable.img2); …
Run Code Online (Sandbox Code Playgroud) 现在我正在使用此函数表情符号:
function emoticons($text) {
$icons = array(
':)' => '<img src="/images/blank.gif" alt="smile" class="icon_smile" />',
':-)' => '<img src="/images/blank.gif" alt="smile" class="icon_smile" />',
':D' => '<img src="/images/blank.gif" alt="smile" class="icon_laugh" />',
':d' => '<img src="/images/blank.gif" alt="laugh" class="icon_laugh" />',
';)' => '<img src="/images/blank.gif" alt="wink" class="icon_wink" />',
':P' => '<img src="/images/blank.gif" alt="tounge" class="icon_tounge" />',
':-P' => '<img src="/images/blank.gif" alt="tounge" class="icon_tounge" />',
':-p' => '<img src="/images/blank.gif" alt="tounge" class="icon_tounge" />',
':p' => '<img src="/images/blank.gif" alt="tounge" class="icon_tounge" />',
':(' => '<img src="/images/blank.gif" alt="sad face" class="icon_sad" />',
':o' => …
Run Code Online (Sandbox Code Playgroud) 我正在开发xmpp-client应用程序.其中一个功能是发送微笑,用户应该能够编辑类似usuall文本.在Viber App中编辑表情符号是我想要实现的最佳示例.
我已经尝试了三种解决问题的方法:
可能有人能给我一些真正有效的解决方案吗?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace abc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
EmoticonRender ab = new EmoticonRender();
private void button1_Click(object sender, EventArgs e)
{
string textie = ab.Parse(textBox1.Text);
richTextBox1.Text += textie+"\n";
}
}
public class EmoticonRender
{
private List<KeyValuePair<string, string>> _dictionary = new List<KeyValuePair<string, string>>()
{
new KeyValuePair<string, string>(":-)", "a.png"),
new KeyValuePair<string, string>(";-(", "a.png"),
};
public string Parse(string text)
{
foreach(KeyValuePair<string, …
Run Code Online (Sandbox Code Playgroud) 我想找一张桌子将旧学校的西洋ascii图释 :-)转换成现代的unicode等效 ☺.
你知道是否有吗?
我想检测一下我是否EditText
包含smilie(表情符号).但我不知道如何检测它们.
我发现您需要 PHP 7 和 MySQL 5.5 才能在要上传到数据库的字符串中使用表情符号。我的服务器上没有这些规范,所以我想在 laravel 或 php 中给出错误消息。
有没有办法检测php中的表情符号?如果是这样,那么我可以创建自定义验证或类似的东西吗?
我已经alpha_dash
在 Laravel 中尝试过验证,但是不可能像这样做一个老派:-)
我正在寻找一种好的,干净的方法来从显示表情符号的richtextbox中复制文本.想想skype,你可以在那里选择聊天,它会复制表情符号图像并将它们转换为文本表示(笑脸图像到:)等).我正在使用MVVM模式.
我正在尝试在 ggplot2 中用表情符号绘制一个情节。我想要的是显示表情符号而不是标签或像 geom 一样显示。Stack 中的这个问题与我的问题非常相似,但它也没有解决它,答案非常手动,我需要自动进行(我的真实数据框有 3000 行)。
只是为了在下面的图中澄清,我想显示表情符号而不是文本标签或条形图。但似乎不可能。
在尝试了不同的解决方案后,我堆积如山,所以任何帮助将不胜感激。我阅读了不同的方式来面对这个问题,比如这里、这里、这里。
我最后一次尝试是这样的:
mult_format <- function() {
function(x) emo::ji(x)
}
ggplot(foo, aes(name_emoji, n)) +
geom_bar(stat = "identity") +
coord_flip() +
scale_y_continuous(labels = mult_format())
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
我的数据看起来像这样,name_emoji 来自emo 包,我也可以将其更改为字节:
name_emoji n emoji
<chr> <int> <chr>
1 closed book 1 "\U0001f4d5"
2 confused face 7 "\U0001f615"
3 dizzy 20 "\U0001f4ab"
4 face with tears of joy 1 "\U0001f602"
5 flexed biceps 1 "\U0001f4aa"
6 light …
Run Code Online (Sandbox Code Playgroud) 我正在尝试清理推文以分析他们的情绪。我想把表情符号变成它们的意思。
例如,我希望我的代码转换
'I ? New York'
'Python is '
Run Code Online (Sandbox Code Playgroud)
到
'I love New York'
'Python is cool'
Run Code Online (Sandbox Code Playgroud)
我见过这样的包,emoji
但他们把表情符号变成了它们所代表的东西,而不是它们的意思。例如,他们把我的推文变成:
print(emoji.demojize('Python is '))
'Python is :thumbs_up:'
print(emoji.demojize('I ? New York'))
'I :heart: New York'
Run Code Online (Sandbox Code Playgroud)
由于“heart”或“thumbs_up”在 中没有正面或负面的含义textblob
,因此这种转换是无用的。但如果“?” 转化为“爱”,情感分析的结果会大幅提升。