【发布时间】:2018-10-27 11:25:20
【问题描述】:
我的应用程序目前存在错误。片段内的 ListView 不显示所有项目。截图如下:
它应该数到 50。但它只数到 30(被删掉了)。
这是我的 ListView 项目行布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView_listview_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/_16sdp"
android:layout_marginTop="@dimen/_4sdp"
android:text="TextView"
android:textAlignment="center"
android:textSize="@dimen/_18ssp"
android:gravity="center"
android:layout_gravity="center_vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout>
</RelativeLayout>
这是我的带有 listView 的片段:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".GeneralFragment">
<ListView
android:id="@+id/listViewGeneral"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
谢谢你:)
【问题讨论】:
-
显示适配器代码
-
设置外部
ReleativeLayout高度为wrap_content。
标签: android android-studio listview