0
我有一個客戶名單show.In的XML我有一個grirdviewConvertview在getview()來空只在第一時間Baseadapter
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<GridView android:id="@+id/customer_list"
style="@style/Widget.SampleDashboard.Grid"
android:layout_width="match_parent"
android:layout_marginTop="10dp"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingLeft="@dimen/horizontal_page_margin"
android:paddingRight="@dimen/horizontal_page_margin"
android:paddingBottom="@dimen/vertical_page_margin"
android:scrollbarStyle="outsideOverlay" />
</LinearLayout>
</ScrollView>
在我使用的是客戶陣列填充適配器代碼。該Baseadapter的getview看起來像下面
@Override
public View getView(int position, View convertView, ViewGroup container) {
String todayortomorrow;
if (convertView == null) {
convertView = getLayoutInflater().inflate(R.layout.customer_detail_list,
container, false);
}
return convertview;
}
我,這是獲得僅顯示一個單一的客戶活動見。原因是convert視圖只在第一次出現null。第二次它不會爲空。如何顯示列表中的所有客戶?
您在'getview()'中的客戶數組''???發佈您的適配器類代碼,並且您沒有爲gridview項目聲明任何視圖,那麼您只是誇大了gridview項目佈局的'customer_detail_list'佈局。 – Pankaj
這不是錯誤(convertView不爲空)。這是適配器的工作方式。 –
convertView!= null是視圖重用的全部概念,這意味着當您的適配器中有1000個項目時,您不必爲視圖充氣1000次,但只需少量,並在滾動時重複使用 – pskink