2012-03-30 52 views
0

我有一個包含以下項目的活動: 活動頂部顯示的動作欄(一個imageview,一個視圖和兩個imagebutton)而對於屏幕的其餘部分,我有一個ListView。這全部放置在main.xml佈局中。該列表將始終有6行不再存在,並且操作欄在此活動中不可見。向上和向下滾動ListView會丟失列表中的頂部和底部項目 - 附帶屏幕截圖

當上下滾動時,listview從某些行中丟失了文本/圖像。

之前滾動(我不得不隱藏標誌雖然,抱歉)

Before scrolling http://img706.imageshack.us/img706/37/32572081.png

滾動向下和向上後(注意DGL查找文本消失)

after first scrolling http://img638.imageshack.us/img638/7334/4scrollup.png

滾動後再次向上(注意DGL查找仍然不存在,危險類別圖文消失得

scrolling again and again http://img839.imageshack.us/img839/4970/5scrolldownagain.png

如果我保持上下滾動,並行可能會再次出現,並可能會消失,以及。

,這裏是我的main.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#FFF" 
    android:orientation="vertical" > 

    <include layout="@layout/action_bar" /> 

    <ImageView 
     android:id="@+id/splashscreen" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_gravity="center" > 
    </ImageView> 

    <ListView 
     android:id="@android:id/list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:cacheColorHint="#00000000" 
     android:textColor="#000" > 
    </ListView> 
</LinearLayout> 

有快捷的幫助!我對Android非常陌生

+1

問題是你實現你的'ViewHolder'和您的適配器實現的說。發佈該代碼。 – Rajkiran 2012-03-30 12:29:38

+1

http://stackoverflow.com/questions/4777272/android-listview-with-different-layout-for-each-row – MKJParekh 2012-03-30 12:40:18

+0

謝謝Rajkiran,我將首先嚐試@Frankenstein解決方案,因爲它聽起來與我的問題非常相關面臨,因爲我有自定義項目/行內的列表視圖。謝謝科學怪人,我明天會更新你 – 2012-04-01 20:06:22

回答

0

@Frankenstein:謝謝你的幫助,你給了我線程頭,我跟着它,直到我得到解決方案。

問題是,listview在屏幕上顯示一定數量的行,並在使用getView方法上下滾動時顯示更多行。顯示的新行通常會採用它們正在替換的行的樣式。

因此,如果row1的字體風格不同於其他字體,那麼將佔用它的那一行將繼承相同的字體風格。你可以做什麼,檢查這是不是應該繼承風格的不同行,然後將風格改變爲你喜歡的風格。

檢查本文http://android.amberfog.com/?p=296這將解釋什麼,我只是一個技術性的方法

相關問題