我有GridView
一个自定义适配器,可以显示来自 RSS 频道的最新 BBC 新闻。我想在GridView
我的 RSS 阅读完成之前加载一个 GIF 图像或 web 视图(这需要 5 秒)。这是我的代码:
private void readRssData() {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
try{
@SuppressWarnings("resource")
RSSReader reader = new RSSReader();
String uri = "http://feeds.bbci.co.uk/news/world/rss.xml";
RSSFeed feed = reader.load(uri);
List<RSSItem> list = feed.getItems();
int c = 0;
for (RSSItem i: list) {
if (c > 15){
break;
}else{
addNewsItemInGrid(i.getTitle(), i.getDescription());
c++;
}
}
}catch (Exception ex){
Toast.makeText(getApplicationContext(), ex.toString(), Toast.LENGTH_SHORT).show();
}finally{
GridView gv = (GridView)findViewById(R.id.gridview);
gv.setAdapter(new RSSAdapter(getApplicationContext(), results));
}
}
}, 3000);
}
private ArrayList<SetAdd> results = new ArrayList<SetAdd>();
private void addNewsItemInGrid(String title, String description) {
SetAdd setadd = new SetAdd();
setadd.setTitle(title);
setadd.setDescription(description);
results.add(setadd);
}
<LinearLayout android:id="@+id/gridview_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/txt_DOTSTEXT"
>
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnWidth="90dp"
android:numColumns="auto_fit"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:stretchMode="columnWidth"
android:gravity="center" >
</GridView>
</LinearLayout>
你怎么看?如何使用图像或 webview 在我的顶部加载图像GridView
?