如何在edittext android中插入jpeg文件

时间:2011-09-28 07:37:13

标签: android android-widget

有没有办法在android中添加jpeg文件到edittext。基本上我在android中创建一个富文本编辑器,它应该有一个显示图像的规定。或者我需要在edittext画布中进行更改。任何建议都会非常有用。

-Regards, 罗恩..

2 个答案:

答案 0 :(得分:1)

编辑:抱歉,我没有花足够的时间阅读。你想要一个带有图片的可编辑,而不是一个简单的TextView。

无论如何,解决方案可能是使用

捕获用户密钥并动态更新webview
webview.loadUrl("javascript:onKeyDown("+keyCode+")");

您需要严格的javascript / java链接。编码可能有些困难,但您不会受到丰富内容的限制。

前回答:

您可能希望使用WebView而不是TextView。

如果您使用简单的HTML提供它们,它们可以非常轻量级。

例如,如果要使用存储在项目myImage.png文件夹中的图像assets,只需使用:

WebView myWebView = (WebView) findViewById(R.id.myWebView);
String richContent = "<html><body>This is text and an <b>Image</b>: <img src=\"file:///android_asset/myImage.png\" /></body></html>";
myWebview.loadData(richContent, "text/html", "utf-8");

答案 1 :(得分:0)

也许你可以使用android-richtexteditor组件。

http://code.google.com/p/android-richtexteditor/

该代码已从官方项目中删除,但在历史记录中仍然可用。

http://android-richtexteditor.googlecode.com/svn-history/r3/trunk/