How to use the Image(Stored Image of device) with

2019-02-06 15:38发布

问题:

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 ImageSpanfor 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