前人未踏の領域へ Androidアプリ開発編

Androidアプリ開発に関する調査メモ置き場。古い記事にはアプリ以外も含まれます。

ListViewに関するべからず集

Google I/O 2010より
http://www.youtube.com/watch?v=wDBM6wVEO70

                    • -
Don't android:layout_height="wrap_content" (ListViewでwrap_contentを使うな) Listview is virtualized, remember? wrap_content = "as big as my children" -- ListViewsupports unevenly sized children -- Measured only 3 children(最初の3つしか見ない) -- Still expensive Wrong result (結果を間違える)
                    • -
Don't ListView inside a ScrollView (ScrollViewとListViewを一緒に使うな) ScrollView scrolls ListView scrolls who will scroll?
                    • -
Don't Cache views in the adapter(Adapter内でViewをキャッシュするな) Don't outsmart ListView - ListView assumes ownership of views Complex recycling mechanism - Numerous optimizations - Sometimes we even leave bugs there Undead views is the worst case - View both in the recycler and on screen
                    • -
Don't Use a ListView when you don't need one! (必要なときにだけ使え) ListView - is for repeating, unbounded data - Adds (lots of) complexity Will a LinearLayout or ScrollView do the job?
      • -
おまけ getView内でのinfrate(resource,root, attachToRoot)のattachToRootは常にfalseにせよ