Skip to content Skip to sidebar Skip to footer

How To Insert Jpeg Files In Edittext Android

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 ma

Solution 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/

Solution 2:

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>: <imgsrc=\"file:///android_asset/myImage.png\" /></body></html>";
myWebview.loadData(richContent, "text/html", "utf-8");

Post a Comment for "How To Insert Jpeg Files In Edittext Android"