Android RSS阅读器描述数据读取错误

编程入门 行业动态 更新时间:2024-10-26 22:24:30
本文介绍了Android RSS阅读器描述数据读取错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发一个Android RSS阅读器,但我面临的问题试图从RSS源,其中描述包含HTML内容,如下面来获取数据时:

I am developing an android rss reader but the problem i am facing is when trying to fetch data from rss feeds where description contain html content like the following:

<item> <title>Katima&#45;Comic</title> <link>thelinknewspaper.ca/article/3063</link> <guid isPermaLink="false">thelink_entry_3063</guid> <description><![CDATA[ <img alt="" width="690" height="407" src="thelinknewspaper.ca/images/cache/c11f5084728aa602d09cd15bb20ae7a86b06be79.jpg" /> </p> <p>This is the story of Andrew Murchison, a Katimavik volunteer whose life was changed by the federal youth program.</p> <p><iframe class="scribd_iframe_embed" src="www.scribd/embeds/101595075/content?start_page=1&view_mode=list&access_key=key-1ss1qrvm5hi9h7othhkq" data-auto-height="true" data-aspect-ratio="0.777636594663278" scrolling="no" id="doc_79691" width="100%" height="600" frameborder="0"></iframe></p> ]]></description> <dc:creator>Paku Daoust&#45;Cloutier</dc:creator> <dc:date>2012-07-31T00:20:54+00:00</dc:date> </item>

我在显示它显示的内容一个TextView的内容与html标签!

I am displaying the content in a textview which displays the content as is with the html tags!

我怎样才能在一个良好的可读的方式与特定的区域内滚动条显示它

How can i display it in a good readable way with a scroll bar inside a specific area

感谢

这里的code我使用的部分内容:

here's a portion of the code i am using:

@Override public View getView(final int position, View convertView, ViewGroup parent) { View view = convertView; ViewHolder holder; if (view == null) { LayoutInflater inflater = (LayoutInflater) activity .getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.row, null); holder = new ViewHolder(); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } if ((items == null) || ((position + 1) > items.size())) return view; objBean = items.get(position); holder.title = (TextView) view.findViewById(R.id.txttitle); holder.description = (TextView) view.findViewById(R.id.txtdesc); if (holder.title != null && null != objBean.getTitle() && objBean.getTitle().trim().length() > 0) { holder.title.setText(Html.fromHtml(objBean.getTitle())); } if (holder.description != null && null != objBean.getDescription() && objBean.getDescription().trim().length() > 0) { holder.description.setText(Html.fromHtml(objBean.getDescription())); } // Even and odd Row... if ((position % 2) == 0) { view.setBackgroundResource(R.drawable.bg_list_even); } else { view.setBackgroundResource(R.drawable.bg_list_odd); } return view; }

public class NewsDetail extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.detail); Bundle b = this.getIntent().getExtras(); String title = b.getString("title"); String desc = b.getString("description"); final String link = b.getString("link"); TextView tvtitle = (TextView) findViewById(R.id.tvtitle); TextView tvdesc = (TextView) findViewById(R.id.tvdesc); Button btnWeb = (Button) findViewById(R.id.btngotolink); btnWeb.setOnClickListener(new OnClickListener() { public void onClick(View v) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link))); } }); tvtitle.setText(title); tvdesc.setText(desc); setTitle(title); } }

感谢再次任何帮助将是非常美联社preciated!

Thank again any help would be really appreciated!!

推荐答案

当您设置文本,将其设置为从HTML文本:

When you set the text, set it as text from html:

tvdesc.setText(Html.fromHtml(desc));

如果你想显示从HTML的图像,您需要使用与网页视图沿着这些路线的东西的:

If you want to show images from the html you'll need to use a WebView with something along these lines:

myWebview.loadData(myHtmlString, "text/html; charset=UTF-8", null);

更多推荐

Android RSS阅读器描述数据读取错误

本文发布于:2023-11-11 21:09:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579567.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阅读器   错误   数据   Android   RSS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!