直播平台软件开发,TextView显示html文字和图片
SimpleDateFormat sdfTwo =new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss",Locale.getDefault());
String time11 = sdfTwo.format(timecurrentTimeMillis);
TextView显示htm图片
private Spanned sp;
new Thread(new Runnable() {
@Override
public void run() {
sp = Html.fromHtml(webText, new Html.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
InputStream is = null;
try {
is = (InputStream) new URL(source).getContent();
Drawable d = Drawable.createFromStream(is, "src");
d.setBounds(0, 0, d.getIntrinsicWidth(),
d.getIntrinsicHeight());
is.close();
return d;
} catch (Exception e) {
return null;
}
}
}, null);
toPhoto(sp);
}
}).start();
//在安卓中不可以在主线程中对UI进行”修改”
private void toPhoto(Spanned sp){
runOnUiThread(new Runnable() {
@Override
public void run() {
dataBinding.tvWeb.setText(sp);
}
});
}
以上就是直播平台软件开发,TextView显示html文字和图片, 更多内容欢迎关注之后的文章
标签:软件开发,sp,html,直播,new,TextView From: https://www.cnblogs.com/yunbaomengnan/p/16624167.html