不寻常的列表视图错误 [英] unusual Listview error

查看:134
本文介绍了不寻常的列表视图错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了保持在SD卡上的视频文件列表和播放一小android应用。我使用的文字和每排两个图像列表视图。我只注意到这个问题是很平常的。在横向模式下,只有适合屏幕区域的列表项显示为正常,而那些谁需要滚动项目得到显现,要么以错误的顺序或他们只是在列表顶部的项目重复。此外,通过上下滚动了起来,有时项目的顺序改变了..我用两个XML文件。首先对列表视图和第二为ListView的内容。这里是code为XML文件

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 ??

推荐答案

当从横向到纵向,反之亦然取向的改变,该活动将重新本身(Activity对象销毁,新的活动对象将创建)参见文档<一个HREF =htt​​p://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges rel=\"nofollow\">http://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges了解更多信息。

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

这篇关于不寻常的列表视图错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆