【发布时间】:2015-05-26 09:49:19
【问题描述】:
我对@987654321@ 有疑问,我使用zsseditor 和WebView 来显示、从键盘输入文本、插入图像或视频。然后,我无法删除段落中的最新字母(几乎我无法删除图像 html 标记)。我通过 CustomWebview 解决了这个问题,删除了图像 html 标签。
public class CustomWebView extends WebView {
/**
* Constructs a new WebView with a Context object.
*
* @param context a Context object used to access application assets
*/
public CustomWebView(Context context) {
super(context);
}
/**
* Constructs a new WebView with layout parameters.
*
* @param context a Context object used to access application assets
* @param attrs an AttributeSet passed to our parent
*/
public CustomWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* Constructs a new WebView with layout parameters and a default style.
*
* @param context a Context object used to access application assets
* @param attrs an AttributeSet passed to our parent
* @param defStyle the default style resource ID
*/
public CustomWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
// http://stackoverflow.com/questions/14560344/android-backspace-in-webview-baseinputconnection
// http://stackoverflow.com/questions/164991Image78/cant-get-backspace-to-work-in-codemirror-under-phonegap-on-android-4-x
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
return new MyCustomInputConnection(this, false);
}
public class MyCustomInputConnection extends BaseInputConnection {
public MyCustomInputConnection(View targetView, boolean fullEditor) {
super(targetView, fullEditor);
}
@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
// magic: in latest Android, deleteSurroundingText(1, 0) will be called for backspace
if (beforeLength == 1 && afterLength == 0) {
// backspace
return super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
&& super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
}
return super.deleteSurroundingText(beforeLength, afterLength);
}
}
}
我将输入键盘换成日语、越南语、泰语或除字母表以外的所有语言。但是当我点击键盘上的按钮字母时,它不会显示在WebView 上。那么如何修复WebView 可以显示每种语言的字母呢?
【问题讨论】:
-
我用其他方法解决了,没有使用img标签