Example usage for android.text Html fromHtml

List of usage examples for android.text Html fromHtml

Introduction

In this page you can find the example usage for android.text Html fromHtml.

Prototype

@Deprecated
public static Spanned fromHtml(String source) 

Source Link

Document

Returns displayable styled text from the provided HTML string with the legacy flags #FROM_HTML_MODE_LEGACY .

Usage

From source file:com.bullmobi.message.ui.DialogHelper.java

public static void showCryDialog(@NonNull ActionBarActivity activity) {
    Check.getInstance().isInMainThread();

    Resources res = activity.getResources();
    CharSequence message = Html.fromHtml(res.getString(R.string.cry_dialog_message));

    new MaterialDialog.Builder(activity).iconRes(R.drawable.ic_action_about_white)
            .title(R.string.cry_dialog_title).content(message).negativeText(R.string.close).build().show();
}

From source file:com.swisscom.safeconnect.json.ResourceJsonParser.java

@Override
protected void parseJson(String json) {
    try {//from  ww  w.ja  va  2  s. co m
        JSONArray jsonArr = new JSONArray(json);

        for (int i = 0; i < jsonArr.length(); i++) {
            JSONObject jsonElem = jsonArr.getJSONObject(i);

            Elem elem = new Elem();
            elem.content = Html.fromHtml(jsonElem.getString("content"));
            elem.title = jsonElem.getString("title");

            result.add(elem);
        }
    } catch (JSONException e) {
        if (BuildConfig.DEBUG)
            Log.e(Config.TAG, "Json error: " + e.getMessage(), e);
    }
}

From source file:com.aniruddhc.acemusic.player.Dialogs.LicensesDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    parentActivity = getActivity();//w w w .jav  a2  s.c  om
    dialogFragment = (DialogFragment) getFragmentManager().findFragmentByTag("licensesDialog");

    rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.licenses_dialog_layout, null);

    creativeCommonsLink = (TextView) rootView.findViewById(R.id.creative_commons_link);
    creativeCommonsLink.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
    creativeCommonsLink.setText(Html.fromHtml(
            "<a href=\"http://creativecommons.org/licenses/by-sa/3.0/legalcode\">Creative Commons ShareALike 3.0 License</a> "));
    creativeCommonsLink.setMovementMethod(LinkMovementMethod.getInstance());

    creativeCommonsInfo = (TextView) rootView.findViewById(R.id.licenses_text);
    creativeCommonsInfo.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    //Set the dialog title.
    builder.setTitle(R.string.licenses);
    builder.setView(rootView);
    builder.setPositiveButton(R.string.done, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            dialogFragment.dismiss();
            getActivity().finish();

        }

    });

    return builder.create();
}

From source file:chaitanya.im.searchforreddit.GenericAlertDialog.java

@SuppressLint("InflateParams")
@Override/*  w ww .  jav a 2 s  .  c om*/
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View dialogView;
    setRetainInstance(true);

    switch (whichDialog) {
    case 0:
        dialogView = inflater.inflate(R.layout.dialog_purchase, null);
        builder.setView(dialogView).setPositiveButton(R.string.ok_purchase, buttonListener);

        final TextView dialogPurchaseTitle = (TextView) dialogView.findViewById(R.id.dialog_purchase_title);
        final TextView purchaseDescription = (TextView) dialogView.findViewById(R.id.purchase_description);
        final TextView priceDisplay = (TextView) dialogView.findViewById(R.id.price_display);
        final TextView coffeePitchText = (TextView) dialogView.findViewById(R.id.coffee_pitch_text);
        coffeePitchText.setTypeface(fontAwesome);
        coffeePitchText.setText(Html.fromHtml(getResources().getString(R.string.donate_coffee_pitch)));

        // SeekBar settings
        AppCompatSeekBar seekBar = (AppCompatSeekBar) dialogView.findViewById(R.id.price_seekbar);
        seekBar.setKeyProgressIncrement(1);
        seekBar.setMax(2);
        seekBar.setProgress(1);

        if (allPrices != null && allPrices.size() != 0) {
            // We can do a purchase since allPrices isn't null
            assert priceDisplay != null;
            priceDisplay.setText(allPrices.get(1));

            if (purchaseDialog == 1) {
                dialogPurchaseTitle
                        .setText(Html.fromHtml(getResources().getString(R.string.donate_dialog_title_2)));
                purchaseDescription.setText(Html.fromHtml(getResources().getString(R.string.donate_features2)));
            }

            skuCode = 1;
            seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
                    skuCode = progress;
                    priceDisplay.setText(allPrices.get(progress));
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {

                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {

                }
            });
        } else {
            // Aw shucks! We cannot do a purchase.
            skuCode = 1;
            seekBar.setEnabled(false);
            priceDisplay.setText(getResources().getString(R.string.donate_impossible));
        }
        return builder.create();
    case 1:
        skuCode = -1;
        dialogView = inflater.inflate(R.layout.dialog_license, null);
        builder.setView(dialogView).setTitle("Licenses").setPositiveButton(R.string.ok_string, buttonListener);
        return builder.create();

    case 2:
        skuCode = -1;
        dialogView = inflater.inflate(R.layout.dialog_about, null);

        builder.setView(dialogView).setPositiveButton(R.string.ok_string, buttonListener);

        int versionCode = BuildConfig.VERSION_CODE;
        String versionName = BuildConfig.VERSION_NAME;
        String versionText = "Version Code <font color=#FF6F00>" + versionCode + "</font><br/>"
                + "Version Name <font color=#FF6F00>" + versionName + "</font><br/>";

        TextView aboutText = (TextView) dialogView.findViewById(R.id.about_text);
        TextView aboutVersion = (TextView) dialogView.findViewById(R.id.about_version);
        TextView aboutCopyright = (TextView) dialogView.findViewById(R.id.about_copyright);
        aboutText.setTypeface(fontAwesome);
        aboutCopyright.setTypeface(fontAwesome);
        aboutText.setText(Html.fromHtml(getResources().getString(R.string.about_text)));
        aboutVersion.setText(Html.fromHtml(versionText));
        aboutCopyright.setText(getResources().getString(R.string.about_copyright));
        return builder.create();

    case 3:
        skuCode = -1;
        dialogView = inflater.inflate(R.layout.dialog_whats_new, null);
        builder.setView(dialogView).setTitle("What's New?").setPositiveButton(R.string.ok_string,
                buttonListener);
        TextView whatsNewText = (TextView) dialogView.findViewById(R.id.whats_new_text);
        whatsNewText.setText(Html.fromHtml(StringResources.whatsNew));
        return builder.create();

    default:
        return builder.create();

    }
}

From source file:com.manning.androidhacks.hack010.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);/*from   w  w  w.ja v  a  2 s.c  om*/

    final TextView textView1 = (TextView) findViewById(R.id.my_text_view_html);
    textView1.setText(Html.fromHtml(getString(R.string.text1)));
    textView1.setMovementMethod(LinkMovementMethod.getInstance());

    final Spannable text2 = new SpannableString(getString(R.string.text2));
    text2.setSpan(new BackgroundColorSpan(Color.RED), 1, 4, 0);
    text2.setSpan(new ForegroundColorSpan(Color.BLUE), 5, 9, 0);

    ((TextView) findViewById(R.id.my_text_view_spannable)).setText(text2);
}

From source file:com.anstar.fieldwork.CaptureSignatureActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.capture_siganture);

    ActionBar action = getSupportActionBar();
    action = getSupportActionBar();//from w  w w  . j a  v  a2s . c o  m
    // action.setTitle("Signature");
    action.setTitle(Html
            .fromHtml("<font color='" + getString(R.string.header_text_color) + "'>Capture Signature</font>"));
    action.setHomeButtonEnabled(true);
    action.setDisplayHomeAsUpEnabled(true);

    Bundle b = getIntent().getExtras();
    if (b != null) {
        if (b.containsKey("cutomer")) {
            signtype = b.getString("cutomer");
        }
        if (b.containsKey("tech")) {
            signtype = b.getString("tech");
        }
        if (b.containsKey(Const.Appointment_Id)) {
            a_id = b.getInt(Const.Appointment_Id);
        }
    }
    appointment_info = AppointmentModelList.Instance().getAppointmentById(a_id);
    llSignCanvas = (LinearLayout) findViewById(R.id.llSignCanvas);
    txtSignType = (TextView) findViewById(R.id.txtSignatureType);
    txtSignName = (TextView) findViewById(R.id.txtSignName);
    txtLicInfo = (TextView) findViewById(R.id.txtSignLic);
    btnCancel = (Button) findViewById(R.id.btnCancel);
    btnClear = (Button) findViewById(R.id.btnClear);
    btnSave = (Button) findViewById(R.id.btnSave);
    m_points = new ArrayList<SignaturePoints>();
    loadView load = new loadView();
    load.execute();
    btnCancel.setOnClickListener(this);
    btnClear.setOnClickListener(this);
    btnSave.setOnClickListener(this);
}

From source file:au.id.tmm.anewreader.view.ItemDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.adapter_view_item_detail, container, false);

    TextView itemTitle = (TextView) view.findViewById(R.id.item_detail_title);
    TextView subscriptionTitle = (TextView) view.findViewById(R.id.item_detail_subscription_title);
    TextView content = (TextView) view.findViewById(R.id.item_detail_content);

    itemTitle.setText(Html.fromHtml(linkWithText(item.getTitle(), item.getCanonicalLink())));
    itemTitle.setMovementMethod(LinkMovementMethod.getInstance());

    subscriptionTitle.setText(Html.fromHtml(
            linkWithText(item.getParentSubscription().getTitle(), item.getParentSubscription().getHtmlUrl())));
    subscriptionTitle.setMovementMethod(LinkMovementMethod.getInstance());

    UrlImageGetter imageGetter = new UrlImageGetter(content, this.getActivity());

    Spanned htmlSpan = Html.fromHtml(item.getSummary(), imageGetter, null);
    content.setText(htmlSpan);/*from   w w  w .j  a v a  2  s  . co m*/
    content.setMovementMethod(LinkMovementMethod.getInstance());

    return view;

}

From source file:com.achep.acdisplay.ui.DialogHelper.java

public static void showCryDialog(@NonNull AppCompatActivity activity) {
    Check.getInstance().isInMainThread();

    Resources res = activity.getResources();
    CharSequence message = Html.fromHtml(res.getString(R.string.cry_dialog_message));

    new MaterialDialog.Builder(activity).iconRes(R.drawable.ic_action_about_white)
            .title(R.string.cry_dialog_title).content(message).negativeText(R.string.close).build().show();
}

From source file:com.temboo.example.YouTubeResultView.java

public YouTubeResultView(Context context, String title, String url, String thumbnailURL) {
    super(context);
    super.setOrientation(HORIZONTAL);

    // Create the link text view, and make the link clickable
    linkView = new TextView(getContext());
    linkView.setMovementMethod(LinkMovementMethod.getInstance());

    // Set the link text
    linkView.append(Html.fromHtml("<a href='" + url + "'>" + title + "</a>"));

    // Populate the image view
    try {//from   w  ww. j av a2  s . c om
        imageView = new ImageView(getContext());
        imageView.setPadding(4, 4, 4, 0);
        fetchDrawableOnThread(thumbnailURL, imageView);
        super.addView(imageView);
    } catch (Exception e) {
        Toast.makeText(getContext(), "An error occurred retrieving the video thumbnail", Toast.LENGTH_LONG)
                .show();
    }
    super.addView(linkView);
}

From source file:at.ac.uniklu.mobile.sportal.DashboardAboutDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AppInfo appInfo = Studentportal.getAppInfo();

    View aboutDialogView = getActivity().getLayoutInflater().inflate(R.layout.about_dialog, null);
    TextView aboutDialogVersionTextView = (TextView) aboutDialogView.findViewById(R.id.about_version_info);
    aboutDialogVersionTextView.setText(getString(R.string.app_version, appInfo.getVersionName()));
    TextView creditsTextView = (TextView) aboutDialogView.findViewById(R.id.credits);
    String creditsText = getString(R.string.credits_iconic) + " / " + getString(R.string.credits_tnp) + " / "
            + getString(R.string.credits_osm) + " / " + getString(R.string.credits_leaflet) + " / "
            + getString(R.string.credits_prevel) + " / " + getString(R.string.credits_gson) + " / "
            + getString(R.string.credits_vpi);
    creditsTextView.setText(Html.fromHtml(creditsText));
    creditsTextView.setMovementMethod(LinkMovementMethod.getInstance());

    aboutDialogView.findViewById(R.id.about_facebook).setOnClickListener(new View.OnClickListener() {
        @Override/*from  www  . j a v  a  2  s . c  o m*/
        public void onClick(View v) {
            startActivity(Utils.getOpenFacebookIntent(getActivity()));
        }
    });

    aboutDialogView.findViewById(R.id.bugsense).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.bugsense.com")));
        }
    });

    return new AlertDialog.Builder(getActivity()).setView(aboutDialogView)
            .setNeutralButton(getString(R.string.close), null).create();
}