NovusMobile
NovusMobile

Reputation: 1833

Android HashMap <String ,Spannable> Issue

Actually I have to use HTML text into data so some one suggest me to use the HashMap<String,Spanned> , I used it but facing error at lots like.

QUESTION LINK : HTML HASHMAP QUESTION RSS FEED

menuItems.addAll(map);

I generally used HashMap<String,String>. Please give your answer on this..

// creating new HashMap
HashMap<String, Spanned> map = new HashMap<String,Spanned>();

Element e = (Element) nl.item(i);


// adding each child node to HashMap key => value

map.put(KEY_DESC, parser.getValue(e, KEY_DESC));
map.put(KEY_TITLE, parser.getValue(e, KEY_TITLE));
map.put(KEY_LINK,parser.getValue(e, KEY_LINK));
map.put(KEY_DATE,parser.getValue(e, KEY_DATE));

//Log.i("desxcr",   map.put(KEY_DESC,parser.getValue(e, KEY_DESC)));
// adding HashList to ArrayList
menuItems.addAll(map);

Upvotes: 0

Views: 480

Answers (1)

waqaslam
waqaslam

Reputation: 68187

It is possible to use Spanned. What you need to do is to use Html.from to put spanned value out from your resource. See below:

Spanned spnd = Html.fromHtml(getString(R.string.your_resource_string));
map.put("yourKey", spnd);

Upvotes: 1

Related Questions