我是一个Android新手,我已经构建了一个简单的基于免费的IBM机器人RSS教程的RSS阅读器应用程序。如果该行的类别等于特定的字符串,我想更改每行的背景颜色。基于我的RSS阅读器的ListView中的内容的行颜色
我写了下面的“for循环”,它发现每个项目的类别,并运行一个if语句,如果该类别等于“新闻”。目前,只要Feed提供新闻类别,整个列表视图的背景颜色就会发生变化。
有没有人觉得像帮助初学者?
for(int i = 0; i < feed.getItemCount(); i++)
{
if (feed.getItem(i).getCategory().equals("News"))
{
ListView.setBackgroundColor(0x77ee0044);
}
}
你能否包含指南的链接,以便我们可以更具体? – 2011-03-04 17:25:33
Hi Matthew,http://www.ibm.com/developerworks/cn/education/xml/x-androidrss/index.html – Mat 2011-03-04 17:27:47
private void UpdateDisplay() {TextView feedtitle =(TextView)findViewById(R.id.feedtitle) ; TextView feedpubdate =(TextView)findViewById(R.id.feedpubdate); ListView itemlist =(ListView)findViewById(R.id.itemlist); ArrayAdapter adapter = new ArrayAdapter (this,android.R.layout.simple_list_item_1,feed.getAllItems()); itemlist.setAdapter(adapter); itemlist.setOnItemClickListener(this); itemlist.setSelection(0); \t \t return; –
Mat
2011-03-04 17:32:39