我的WebView出现问题。当我使用TextView从firebase调用数据时它完全正常工作,但是当我使用WebView从firebase调用数据时(参见下面的代码),除非我退出应用程序并再次运行,否则数据根本不会显示。
public static class LessonListViewHolder extends RecyclerView.ViewHolder{
String justifyTag = "<html><body style='text-align:justify;LINE-HEIGHT:20px;font-size:12px;padding-top:10px;padding-left:5px;padding-right:5px;'>%s</body></html>";
View mView;
public LessonListViewHolder(View itemView) {
super(itemView);
mView = itemView;
}
public void setData_one(String data_one){
//TextView post_lesson1 = (TextView) mView.findViewById(R.id.post_lesson1);
//post_lesson1.setText(data_one);
WebView post_lesson1 = (WebView) mView.findViewById(R.id.post_lesson1);
String dataString = String.format(Locale.US, justifyTag, data_one);
post_lesson1.loadDataWithBaseURL("", dataString, "text/html", "UTF-8", "");
}
public void setData_two(String data_two){
//TextView post_lesson2 = (TextView) mView.findViewById(R.id.post_lesson2);
//post_lesson2.setText(data_two);
WebView post_lesson2 = (WebView) mView.findViewById(R.id.post_lesson2);
String dataString = String.format(Locale.US, justifyTag, data_two);
post_lesson2.loadDataWithBaseURL("", dataString, "text/html", "UTF-8", "");
}
public void setData_image (final Context ctx, final String data_image){
final ImageView post_image = (ImageView) mView.findViewById(R.id.post_image);
Picasso.with(ctx).load(data_image).networkPolicy(NetworkPolicy.OFFLINE).into(post_image, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError() {
Picasso.with(ctx).load(data_image).into(post_image);
}
});
}
}