开发者

how to insert jpeg files in edittext android

Is there any way to add jpeg files to edittext in android. B开发者_运维知识库asically i am creating a rich text editor in android which should have a provision to display images. Or do i need to make changes in edittext canvas for that. Any suggestions would be really helpful.

-Regards, Ron..


Maybe you could use the android-richtexteditor component.

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

The code has been deleted from the official project but it is still available in the history.

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


EDIT: Sorry I did not take enough time to read. You wanted an Editable with picture, not a simple TextView.

Anyway, the solution is maybe to catch user keys and update a webview on the fly using

webview.loadUrl("javascript:onKeyDown("+keyCode+")");

You will need tight javascript/java linking. It can be somewhat tough to code but you will not be limited in terms of rich content.

Former answer:

You may want to use a WebView instead of a TextView.

They can be very lightweight if you feed them with simple HTML.

For example, if you want to use the image myImage.png that you stored in your project assets folder, simply use:

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");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜