首页 \ 问答 \ Listview无法显示最后一项(Listview can't displayed the last item)

Listview无法显示最后一项(Listview can't displayed the last item)

这是我目前的listivew: 在此处输入图像描述

我的问题是我无法在列表中显示我的最后一项。 就像被手机切断一样。

这是xml代码:

  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1">
    <RelativeLayout
        android:orientation="vertical"
        android:id="@+id/border"
        android:layout_width="match_parent"
        android:layout_height="280dp"

        android:background="@drawable/dfcomment3"
        android:layout_weight="0.07">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:text="Add comment"
                android:id="@+id/button12"
                android:layout_marginTop="215dp"
                android:layout_marginLeft="5dp" />
            <Button
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:text="Update Post"
                android:id="@+id/button13"
                android:layout_marginTop="215dp" />
            <Button
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:text="Close This"
                android:id="@+id/button14"
                android:layout_marginTop="215dp" />


        </LinearLayout>

        <TextView
            android:layout_marginLeft="10dp"
            android:textSize="35dp"
            android:id="@+id/textView11"
            android:gravity="center"
            android:text="ID"
            android:textStyle="bold"
            android:textColor="#994495"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/textView12"
            android:text="Name"
            android:textSize="16dp"
            android:textColor="#994495"
            android:layout_marginTop="190dp"
            android:layout_marginLeft="210dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/textView13"
            android:text="Lastname"
            android:textStyle="bold"
            android:textSize="16dp"
            android:layout_marginLeft="90dp"
            android:textColor="#994495"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/id"
            android:layout_toEndOf="@+id/id"
            android:layout_marginTop="5dp" />

        <TextView
            android:id="@+id/textView14"
            android:text="title"
            android:textSize="15dp"
            android:textColor="#994495"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="260dp"
            android:layout_below="@+id/name"
            android:layout_alignStart="@+id/name"
            android:layout_marginTop="190dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="descr"
            android:textSize="21dp"
            android:textColor="#994495"
            android:id="@+id/textView15"
            android:layout_marginLeft="110dp"
            android:layout_marginTop="60dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="dept"
            android:textStyle="italic"
            android:textColor="#994495"
            android:id="@+id/textView16"
            android:layout_marginLeft="180dp"
            android:layout_marginTop="30dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="tags"
            android:textStyle="italic"
            android:textSize="14dp"
            android:textColor="#994495"
            android:id="@+id/textView17"
            android:layout_marginLeft="120dp"
            android:layout_marginTop="30dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="status"
            android:textSize="25dp"
            android:textStyle="bold"
            android:textColor="#70CC86"
            android:id="@+id/textView18"
            android:layout_marginLeft="290dp"
            android:layout_marginTop="10dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="date"
            android:textColor="#994495"
            android:id="@+id/textView19"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="190dp" />
    </RelativeLayout>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:layout_height="match_parent" >

        <ListView
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>
</LinearLayout>

我想尽可能地坚持使用listview,因为我不熟悉recyclerview。 如果有任何解决方法,我会很高兴。 检查图像以获取我的问题的参考。

列表中实际上有4个项目,我只能查看2个项目。


This is the my current listivew: enter image description here

My problem is i can't display my last item in the list. It's like getting cut by my phone.

Here is the xml code:

  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1">
    <RelativeLayout
        android:orientation="vertical"
        android:id="@+id/border"
        android:layout_width="match_parent"
        android:layout_height="280dp"

        android:background="@drawable/dfcomment3"
        android:layout_weight="0.07">


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <Button
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:text="Add comment"
                android:id="@+id/button12"
                android:layout_marginTop="215dp"
                android:layout_marginLeft="5dp" />
            <Button
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:text="Update Post"
                android:id="@+id/button13"
                android:layout_marginTop="215dp" />
            <Button
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:text="Close This"
                android:id="@+id/button14"
                android:layout_marginTop="215dp" />


        </LinearLayout>

        <TextView
            android:layout_marginLeft="10dp"
            android:textSize="35dp"
            android:id="@+id/textView11"
            android:gravity="center"
            android:text="ID"
            android:textStyle="bold"
            android:textColor="#994495"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/textView12"
            android:text="Name"
            android:textSize="16dp"
            android:textColor="#994495"
            android:layout_marginTop="190dp"
            android:layout_marginLeft="210dp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/textView13"
            android:text="Lastname"
            android:textStyle="bold"
            android:textSize="16dp"
            android:layout_marginLeft="90dp"
            android:textColor="#994495"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/id"
            android:layout_toEndOf="@+id/id"
            android:layout_marginTop="5dp" />

        <TextView
            android:id="@+id/textView14"
            android:text="title"
            android:textSize="15dp"
            android:textColor="#994495"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="260dp"
            android:layout_below="@+id/name"
            android:layout_alignStart="@+id/name"
            android:layout_marginTop="190dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="descr"
            android:textSize="21dp"
            android:textColor="#994495"
            android:id="@+id/textView15"
            android:layout_marginLeft="110dp"
            android:layout_marginTop="60dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="dept"
            android:textStyle="italic"
            android:textColor="#994495"
            android:id="@+id/textView16"
            android:layout_marginLeft="180dp"
            android:layout_marginTop="30dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="tags"
            android:textStyle="italic"
            android:textSize="14dp"
            android:textColor="#994495"
            android:id="@+id/textView17"
            android:layout_marginLeft="120dp"
            android:layout_marginTop="30dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="status"
            android:textSize="25dp"
            android:textStyle="bold"
            android:textColor="#70CC86"
            android:id="@+id/textView18"
            android:layout_marginLeft="290dp"
            android:layout_marginTop="10dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="date"
            android:textColor="#994495"
            android:id="@+id/textView19"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="190dp" />
    </RelativeLayout>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:layout_height="match_parent" >

        <ListView
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>
</LinearLayout>

As much as possible i want to stick with the listview because i'm not familiar with the recyclerview. if theres any way to fix this, i would be glad. Check the image for the reference of my problem.

There's actually 4 items in the list and i can only view 2 items.


原文:https://stackoverflow.com/questions/43962424
更新时间:2023-04-04 15:04

最满意答案

是的,这是一个RDD,而不是一个Python对象,您可以将其排序,就像它是本地集合一样。 但是在groupByKey()之后,每个键值元组中的值是一个数字集合,这是你想要排序的吗? 您可以使用mapValues() sorted()在其参数上调用sorted()

我意识到这是一个玩具示例,但要小心groupByKey因为它必须获取内存中键的所有值。 此外,甚至不一定能保证具有2个元素的RDD和2个分区,意味着1进入每个分区。 这很可能,但不是讽刺。

PS你应该能够用values()替换map(lambda x: x[1]) values() 。 它可能更快。


Yes, that's an RDD, not a Python object that you can sort as if it's a local collection. After groupByKey() though, the value in each key-value tuple is a collection of numbers, and that is what you want to sort? You can use mapValues() which called sorted() on its argument.

I realize it's a toy example but be careful with groupByKey as it has to get all values for a key in memory. Also it is not even necessarily guaranteed that an RDD with 2 elements, and 2 partitions, means 1 goes in each partition. It's probable but not guarnateed.

PS you should be able to replace map(lambda x: x[1]) with values(). It may be faster.

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。