1

Is there any way to add jpeg files to edittext in android. Basically 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..

Ron
  • 359
  • 6
  • 21

2 Answers2

1

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/

Dyonisos
  • 3,541
  • 2
  • 22
  • 25
  • Hi, I checked this link but i am not able to find any source code or any demo. I think the project got deleted from code.google.com. – Ron Sep 28 '11 at 07:57
  • I did not recognize, that the code has been deleted. I will try to find a backup mirror. – Dyonisos Sep 28 '11 at 08:58
  • I found the code in the svn history of the project. See my updated answer. – Dyonisos Sep 28 '11 at 09:05
  • Thanks :) i am able to see through r3 revision. And it is working fine. – Ron Sep 28 '11 at 11:18
1

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");
Laurent'
  • 2,611
  • 1
  • 14
  • 22