Skip to content Skip to sidebar Skip to footer

How To Make Dynamic Text Bold Having Tag In Listview?

I'm developing an application in which I'm parsing JSON data and fixing the result in the listview. In JSON response I'm getting the following response: { 'searchdata': { 'webr

Solution 1:

You can use SimpleAdapter.ViewBinder and set a html value to the TextView instead of plain text.

SimpleAdapter adapter = newSimpleAdapter(getApplicationContext(), searchList, R.layout.list_row, newString[] { "title","description", "link" }, new int[] { R.id.title,R.id.desc, R.id.url });
SimpleAdapter.ViewBinder binder = newSimpleAdapter.ViewBinder() {
    @OverridepublicbooleansetViewValue(View view, Objectobject, String value) {
        if (view instanceofTextView) {
            ((TextView) view).setText(Html.fromHtml(value));
            returntrue;
        }

        returnfalse;
    }
};

adapter.setViewBinder(binder);
setListAdapter(adapter);

Solution 2:

Use Html.fromHtml() before you put in to Map

map.put("title", HTML.fromHtml(title));
map.put("description", HTML.fromHtml(desc));
map.put("link", HTML.fromHtml(link));

Solution 3:

Just use SpannedString instead of normal string and then display it on TextView using setText().

Example: SpannedString spannedText = new SpannedString(Html.fromHtml(value)); textView.setText(spannedText);

Solution 4:

In Adapter class while setting the title just try as fallow.

holder.title.setText(Html.fromHtml(searchList.getTitle)).

Post a Comment for "How To Make Dynamic Text Bold Having Tag In Listview?"