gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 18:09:04 26 4
gpt4 key购买 nike

我正在开发一个 android rss 阅读器,但我面临的问题是在尝试从 rss 提要中获取数据时,其中描述包含如下 html 内容:

<item>
<title>Katima&#45;Comic</title>
<link>http://thelinknewspaper.ca/article/3063</link>

<guid isPermaLink="false">thelink_entry_3063</guid>
<description><![CDATA[


<img alt="" width="690" height="407" src="http://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="http://www.scribd.com/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 标签一样!

如何在特定区域内使用滚动条以易于阅读的方式显示它

谢谢

这是我使用的部分代码:

@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);
}

}

再次感谢任何帮助将不胜感激!!

最佳答案

设置文本时,将其设置为html中的文本:

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

如果你想显示来自 html 的图像,你需要使用 WebView沿着这些方向:

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

关于Android RSS阅读器描述数据获取错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11747702/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com