Android 的 listView 中使用 addFooterView 無作用

已有一個 listView

最後為了底部加上廣告 (AdMob)

於是  listView.addFooterView(廣告的 view);

但總是出不來廣告

解決方式

將 addFooterView() 改在 listView.setAdapter(某個adapter) 之前 即可

 

例:

原本

[sourcecode language=”java”]

listView.setAdapter(某個adapter);

listView.addFooterView(廣告的view);

[/sourcecode]

 

改為

[sourcecode language=”java”]
listView.addFooterView(廣告的view);
listView.setAdapter(某個adapter);
[/sourcecode]

就這樣

資料來源 : http://stackoverflow.com/questions/12011909/listview-addfooterviewv-not-displaying

13 關於 “Android 的 listView 中使用 addFooterView 無作用” 的評論

  1. treasure hunt adventure

    naturally like your web site but you have to test the spelling
    on quite a few of your posts. Many of them are rife with spelling issues and I to find it very bothersome to tell the truth
    on the other hand I will certainly come back again.

    回覆
  2. Portal

    Idealny artykuł, w sumie się z Tobą zgadzam, jednakże w niektórych kwestiach bym się kłóciła.
    Na pewno Twój blog zasługuje na szacunek. Jestem pewna, że tu jeszcze wpadnę.

    回覆
  3. Super Dancer Season 1

    After I originally commented I appear to have
    clicked the -Notify me when new comments are added- checkbox and now whenever a comment is added I recieve four emails with the same comment.
    Perhaps there is a means you can remove me
    from that service? Kudos!

    回覆

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *