简体   繁体   中英

Scrolling up and down the ListView loses the top and bottom items in the list - Screenshot attached

I have an activity with the following items: Action bar (one imageview, one view and two imagebutton) displayed on top of the activity, and for the rest of the screen I have one ListView. This is all placed in main.xml layout. The list will always have 6 rows no more and the action bar is not visible on this activity.

The listview loses text/images from some rows when scrolling up and down.

Before scrolling (I had to hide the logo though, sorry)

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

After scrolling down and up (note DGL Lookup text disappear)

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

After scrolling down and up again (note DGL Lookup is still not there and Hazard Classes graphic and text disappear too

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

If I keep scrolling up and down, rows might show up again and might disappear as well.

here is my 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>

Any quick help! I am very new to Android

@Frankenstein: Thanks for your help, you gave me the thread head and I followed it until the I got the solution.

The issue was that the listview display certain number of rows on a screen, and display more rows as you scroll up and down using getView method. The new rows displayed will normally take the style of the rows they are replacing.

So, if row1 has a different font style than others, then the row that will take it's place will inherit the same font style. What you may do, check if this is a different row that shouldn't inherit the style and then change the style to what you like.

Check this article http://android.amberfog.com/?p=296 which will explain what I just said in a technical way

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM