I am creating the chat app , in which i am getting the EMOJI from the server (IMAGE URLS).
I am using this images(Emoji url) with text in my TextView
by below lines of the code.
String stringWithHtml = "Sample string with an <img src=\"http://MY_SERVER.emoji.s3.amazonaws.com/cf68/5794d5f7895fa10a8f8e1350/imgList/5794d5f7895fa10a8f8e136a.png\"></img>" +
"<img src=\"http://MY_SERVER.emoji.s3.amazonaws.com/cf68/5794d5f7895fa10a8f8e1350/imgList/5794d5f7895fa10a8f8e135a.png\"></img>"+
"<img src=\"http://MY_SERVER.emoji.s3.amazonaws.com/cf68/5794d5f7895fa10a8f8e1350/imgList/5794d5f7895fa10a8f8e135b.png\"></img>";
Drawable drawable = Drawable.createFromStream(new URL(source).openStream(), "src name");
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
Spanned spannedValue = Html.fromHtml(stringWithHtml, drawable, null);
MY_TEXTVIEW.setText(spannedValue);
This all stuff , i am using in the AsynTask
and getting the expected result like below:-
Now i am storing all the emojis(Images) on my device and want to use it with text in my TextView
.
My question is that How can we use the device(Stored images) with text on my TextView ?
I have searched about it on SO but did not get the expected result.Please check below link which i have visited.
1. First Link
2. Second Link
3. Third Link
4. Forth Link
I have used the ImageSpan
for it but the other problem arises , which i have posted the question on SO Click here
Please help me to short out from this problem.Thanks
OK. You even no need Uri. try this:
Here is the code for loading images in textview from servers as well as from sdcard.. you can use sdcard related code :)
ImageGetter
URLDrawable
You can use emojicon library , also refer here , sample source code included.
you can add custom emojis like below
You can implement a java program to get the count of the emoji's you receive.
And Dynamically create ImageView component in the UIView using the below program. Please use looping structures to repeat as much as you need.