android - How to make listview more efective? -
from old google presentation remember should never utilize android:layout_height = "wrap_content" still true? of next layout better? autogenerated implementation
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <listview android:id="@+id/listview1" android:layout_width="match_parent" android:layout_height="wrap_content" > </listview> </linearlayout> limited availible height
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <listview android:id="@+id/listview1" android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" > </listview> </linearlayout> surrounded layout
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="0dip" android:layout_weight="1" > <listview android:id="@+id/listview1" android:layout_width="match_parent" android:layout_height="match_parent" > </listview> </linearlayout> </linearlayout>
you should never utilize wrap_content because create listview calculate total height, , involve go throughout list items initialise them , views still true should never ever utilize wrap_content.
in 3rd alternative surround in linearlayout useless because listview can moved upper parent , saving 1 level in view hierarchy such:
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <listview android:id="@+id/listview1" android:layout_width="match_parent" android:layout_height="match_parent"> </listview> the sec version achieves same version im giving, uses layout_weight difference on using version post here , sec depends on you're trying accomplish, version post create listview height equal parent while sec version distribute remaining height between listview , other views place within linearlayout
android android-listview
No comments:
Post a Comment