Android解析富文本

今天后台返回富文本格式数据,找了一个第三方库

在build.gradle文件的dependencies中

    implementation('com.github.sendtion:XRichText:1.5') {
        exclude group: 'com.android.support'
        exclude group: 'com.github.bumptech.glide'
    }
因为我用的sdk是26的必须配置下面两行代码,如果是27以上含27则不用写 
exclude group: 'com.android.support'
 exclude group: 'com.github.bumptech.glide'

配置好后xml文件:写一个

    

        

            

        
    

Java文件中

   RichText.from(guangbobean.data.content)
                .imageClick(new OnImageClickListener() {
                    @Override
                    public void imageClicked(List imageUrls, int position) {
                        Calendar calendar = Calendar.getInstance();
                        int m = calendar.get(Calendar.MINUTE);
                        int s = calendar.get(Calendar.SECOND);
                    }
                }).into(tvNoteContent);



你可能感兴趣的:(Android第三库)