开发者

unusual Listview error

开发者 https://www.devze.com 2023-03-17 12:32 出处:网络
I made a small android application that maintains a list of video files on the sd-card and plays it. I am using a listview with text and two images in each row. The problem I just noticed is quite usu

I made a small android application that maintains a list of video files on the sd-card and plays it. I am using a listview with text and two images in each row. The problem I just noticed is quite usual. In horizontal mode, only those list items that fit into the screen area appears as normal while those items who require scrolling to get appeared, are either in wrong order or they are just repetition of the items in the top of the list. Moreover, by scrolling up and down, sometimes the order of items changes.. I am using two xml files. First for list view and second for the contents of the listview. here is the code for both xml files

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
    android:id="@+id/list"
    android:listSelector="@android:color/transparent"
    android:divider="@drawable/bwgradient"
    android:dividerHeight="1.5px"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    />

</LinearLayout>


<?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="wrap_content">
 <ImageView
  android:id="@+id/image"
  android:layout_width="50dip"
  android:layout_height="50dip" 
  android:layout_marginTop="2dip"
  android:layout_marginBottom="2dip"
  android:src="@drawable/cover" 
  android:scaleType="centerCrop"/>

 <TextView
  android:id="@+id/text"
  android:state_focused="false"
  android:listSelector="#00000000"
  android:layout_开发者_运维百科width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_weight="1" 
  android:layout_gravity="left|center_vertical" 
  android:textSize="14dip" 
  android:layout_marginLeft="20dip"/>
  <ImageView
  android:id="@+id/play"
  android:layout_width="30dip"
  android:layout_height="30dip" 
  android:src="@drawable/play" 
  android:onClick="imageClick"
  android:layout_gravity="center"
  android:layout_marginRight="20dip"
  android:scaleType="centerCrop"/>
  </LinearLayout>

Any possible suggestion ??


when orientation changes from horizontal to portrait and vice verse,the activity will recreate itself(the Activity object destroyed and new Activity object will create).See docs http://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges for more information

0

精彩评论

暂无评论...
验证码 换一张
取 消