bobomee / mentions Goto Github PK
View Code? Open in Web Editor NEWmention string(@xxxx,#xxx#,links) support EditText ,TextView for Android
mention string(@xxxx,#xxx#,links) support EditText ,TextView for Android
因为 Html.fromHtml 对\n 无效。
原:
return Html.fromHtml(sourceString, null, new HtmlTagHandler());
改为
return Html.fromHtml(sourceString.replace("\n","<br />"), null, new HtmlTagHandler());
如题
能不能 删除span的时候,直接删除,而不是点击删除先选中span,在点击删除,才算完成删除,我想点击一次就删除,类似今日头条的删除功能
测试过程中发现在华为和vivo上级上出现这个问题,小米手机上没事。
出现问题的原因是,达到快速删除的时候,vivo手机上会一次删除两个字符,华为手机上就***
贴上解决代码,直接修改MentionInputConnection类sendKeyEvent就可以
` private int lastStart=-1;
private int lastend=-1;
@OverRide public boolean sendKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
if (null != mRangeManager) {
int selectionStart = mEditText.getSelectionStart();
int selectionEnd = mEditText.getSelectionEnd();
if (lastStart==selectionStart && lastend==selectionEnd){
return true;
}
Range closestRange =
mRangeManager.getRangeOfClosestMentionString(selectionStart, selectionEnd);
if (closestRange == null) {
mEditText.setSelected(false);
if (selectionStart>0) {
mEditText.getEditableText().delete(selectionStart - 1, selectionEnd);
return true;
}else {
mEditText.setSelected(false);
return super.sendKeyEvent(event);
}
}
//if mention string has been selected or the cursor is at the beginning of mention string, just use default action(delete)
if (mEditText.isSelected() || selectionStart == closestRange.getFrom()) {
mEditText.setSelected(false);
lastStart=selectionStart;
lastend=selectionEnd;
return super.sendKeyEvent(event);
} else {
//select the mention string
if (isDeletable) {//可以删除,否则不进行处理
mEditText.setSelected(true);
mRangeManager.setLastSelectedRange(closestRange);
setSelection(closestRange.getTo(), closestRange.getFrom());
}
}
return true;
}
}
return super.sendKeyEvent(event);
}
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.