1
我有一個GridView
與自定義適配器,顯示RSS頻道的最新BBC新聞。我想在GridView
的頂部加載GIF圖像或webview,直到我的RSS閱讀完成(需要5秒鐘)。這是我的代碼:覆蓋gridview頂部的圖像視圖
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
上加載圖像?
這樣做的伎倆,謝謝。 –