Monday 26 December 2016

Html.fromHtml Deprecated In Android

  No comments
/*    
**************Gangs of coder by Suraj Bahadur*****************You have to add a version check and use the old method on Android M and below, on Android N and higher you should create new method for this. If you don't add a version check your app will break on lower Android versions or crash  so it's totally depend on you how you want to implement the login */

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
    x.setText(Html.fromHtml(sx,Html.FROM_HTML_MODE_LEGACY));
} else {
    x.setText(Html.fromHtml(sx));
}



Below are flag parameter

public static final int FROM_HTML_MODE_COMPACT = 63;
public static final int FROM_HTML_MODE_LEGACY = 0;
public static final int FROM_HTML_OPTION_USE_CSS_COLORS = 256;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_BLOCKQUOTE = 32;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_DIV = 16;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_HEADING = 2;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_LIST = 8;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_LIST_ITEM = 4;
public static final int FROM_HTML_SEPARATOR_LINE_BREAK_PARAGRAPH = 1;
public static final int TO_HTML_PARAGRAPH_LINES_CONSECUTIVE = 0;
public static final int TO_HTML_PARAGRAPH_LINES_INDIVIDUAL = 1;

No comments :

Post a Comment

Loading...