Я хочу использовать Html .ImageGetter для получения изображений URL и отображения их в текстовом представлении. Мне удалось получить уже существующее изображение из html и показать его в текстовом виде. Кто-нибудь поможет мне изменить мой код, чтобы получить изображение по URL-адресу и отобразить его в текстовом виде.
public class MainActivity extends Activity
{
Button b1;
EditText ed1;
private WebView wv1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textView=findViewById(R.id.textview);
String htmlText = "Hai<br><img src=\"ic_launcher_background\"><br>Hello";
textView.setText(Html.fromHtml(htmlText, new Html.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
int resourceId = getResources().getIdentifier(source, "drawable",getPackageName());
Drawable drawable = getResources().getDrawable(resourceId);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
return drawable;
}
}, null));
}
}```