在android上的联系方式,如滚动列表

在android上的联系方式,如滚动列表,第1张

概述我正在编写我的第一个 Android应用程序(我在Android上是一个菜鸟,但在java上不错).该应用程序的第一个屏幕包含一个巨大的列表(大约1.5K项)的漫画对象.我使用的代码如下: main.xml中: <?xml version="1.0" encoding="utf-8"?><LinearLayout android:id="@+id/LinearLayout01" 我正在编写我的第一个 Android应用程序(我在AndroID上是一个菜鸟,但在java上不错).该应用程序的第一个屏幕包含一个巨大的列表(大约1.5K项)的漫画对象.我使用的代码如下:

main.xml中:

<?xml version="1.0" enCoding="utf-8"?><linearLayout androID:ID="@+ID/linearLayout01"        androID:layout_wIDth="fill_parent"        androID:layout_height="fill_parent"        xmlns:androID="http://schemas.androID.com/apk/res/androID">        <ListVIEw androID:layout_height="fill_parent"            androID:layout_wIDth="fill_parent"            androID:ID="@+ID/androID:List"></ListVIEw>        <TextVIEw androID:layout_height="fill_parent"            androID:layout_wIDth="fill_parent"            androID:text="@string/List_no_items"            androID:ID="@+ID/androID:empty"></TextVIEw></linearLayout>

row.xml:

<linearLayout androID:ID="@+ID/linearLayout01"              androID:layout_wIDth="fill_parent"               androID:layout_height="?androID:attr/ListPreferredItemHeight"              androID:padding="6dip"              xmlns:androID="http://schemas.androID.com/apk/res/androID">    <ImageVIEw        androID:ID="@+ID/icon"        androID:layout_wIDth="wrap_content"        androID:layout_height="fill_parent"        androID:layout_marginRight="6dip"        androID:src="@drawable/icon" />    <linearLayout        androID:orIEntation="vertical"        androID:layout_wIDth="0dip"        androID:layout_weight="1"        androID:layout_height="fill_parent">        <TextVIEw            androID:ID="@+ID/toptext"            androID:layout_wIDth="fill_parent"            androID:layout_height="0dip"            androID:layout_weight="1"            androID:gravity="center_vertical"        />        <TextVIEw            androID:layout_wIDth="fill_parent"            androID:layout_height="0dip"            androID:layout_weight="1"             androID:ID="@+ID/bottomtext"            androID:singleline="true"            androID:ellipsize="marquee"        />    </linearLayout></linearLayout>

然后我有一个适配器,它基本上采用一个Manga对象并将其名称放在行toptext中,并且它是最新更新的日期.但是,(这可能是由于单元的虚拟化引起的),结果非常慢.滚动列表需要永远,你只能滚动时间的小和平.如何使列表与contacts-app中的列表一样工作?因此,当你开始滚动时,屏幕右侧d出一个手柄,当你拖动它时,字母会显示你滚动的距离(列表按字母顺序排序),还有,有一种方法我可以提高名单的表现吗?

解决方法 要添加拇指滚动条,请在main.xml中调整ListVIEw,如下所示:

<ListVIEw androID:layout_height="fill_parent"        androID:layout_wIDth="fill_parent"        androID:ID="@+ID/androID:List"        androID:fastScrollEnabled="true"></ListVIEw>

添加androID:fastScrollEnabled =“true”属性.

https://developer.android.com/reference/android/widget/AbsListView.html#attr_android:fastScrollEnabled

你也可以看看使用SectionIndexer.

总结

以上是内存溢出为你收集整理的在android上的联系方式,如滚动列表全部内容,希望文章能够帮你解决在android上的联系方式,如滚动列表所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1121697.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存