A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© a6566983 初级黑马   /  2014-10-26 09:51  /  1150 人查看  /  5 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     android:layout_width="fill_parent"
  4.     android:layout_height="fill_parent"
  5.     android:orientation="vertical" >

  6.     <include
  7.         android:id="@+id/title"
  8.         android:layout_width="fill_parent"
  9.         android:layout_height="wrap_content"
  10.         layout="@layout/head_left_right" />

  11.     <RelativeLayout
  12.         android:layout_width="fill_parent"
  13.         android:layout_height="fill_parent" >
  14.         
  15.          <ListView
  16.              android:id="@+id/lv"
  17.              android:layout_width="fill_parent"
  18.              android:layout_height="wrap_content"
  19.              android:layout_alignParentTop="true" />

  20.         <TextView
  21.             android:id="@+id/tv"
  22.             android:layout_width="fill_parent"
  23.             android:layout_height="wrap_content"
  24.             android:layout_below="@+id/lv"
  25.             android:layout_gravity="center_vertical" />

  26.         <LinearLayout
  27.             android:id="@+id/line"
  28.             android:layout_width="fill_parent"
  29.             android:layout_height="50dp"
  30.             android:layout_below="@+id/tv"
  31.             android:gravity="center"
  32.             android:layout_alignParentBottom="true"
  33.             android:orientation="horizontal" >

  34.             <Button
  35.                 android:id="@+id/bt_selectall"
  36.                 android:layout_width="80dp"
  37.                 android:layout_height="fill_parent"
  38.                 android:text="全选" />

  39.             <Button
  40.                 android:id="@+id/bt_cancleselectall"
  41.                 android:layout_width="80dp"
  42.                 android:layout_height="fill_parent"
  43.                 android:text="反选" />

  44.             <Button
  45.                 android:id="@+id/bt_deselectall"
  46.                 android:layout_width="80dp"
  47.                 android:layout_height="fill_parent"
  48.                 android:text="取消选择" />
  49.         </LinearLayout>

  50.     </RelativeLayout>

  51. </LinearLayout>
复制代码
这段代码,为什么listView下面的就不显示了,求高人指教

评分

参与人数 1技术分 +1 收起 理由
敏敏好学 + 1 楼主已经学到安卓了

查看全部评分

5 个回复

正序浏览
kid1943 发表于 2014-10-28 08:26
你在listview中加上android:layout_weight="1" 试试

不会意思撸主 我以为你的是Linearlayou 应该指定好listview的高度例如指定为400dip,还有就是 android:layout_below="@+id/lv"前面不要加+号。改后的代码 大概如下
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     android:layout_width="fill_parent"
  4.     android:layout_height="fill_parent"
  5.     android:orientation="vertical" >

  6.     <RelativeLayout
  7.         android:layout_width="fill_parent"
  8.         android:layout_height="fill_parent" >
  9.         
  10.          <ListView
  11.              android:id="@+id/lv"
  12.              android:layout_width="fill_parent"
  13.            android:layout_height="400dip"
  14.            android:layout_alignParentTop="true" />

  15.         <TextView
  16.             android:id="@+id/tv"
  17.             android:layout_width="fill_parent"
  18.             android:layout_height="wrap_content"
  19.             android:layout_below="@id/lv"
  20.             android:layout_gravity="center_vertical"
  21.             android:text="啊啊啊啊啊啊啊啊啊啊啊啊啊"
  22.             />

  23.         <LinearLayout
  24.             android:id="@+id/line"
  25.             android:layout_width="fill_parent"
  26.             android:layout_height="50dp"
  27.             android:layout_below="@id/tv"
  28.             android:gravity="center"
  29.             android:layout_alignParentBottom="true"
  30.             android:orientation="horizontal" >

  31.             <Button
  32.                 android:id="@+id/bt_selectall"
  33.                 android:layout_width="80dp"
  34.                 android:layout_height="fill_parent"
  35.                 android:text="全选" />

  36.             <Button
  37.                 android:id="@+id/bt_cancleselectall"
  38.                 android:layout_width="80dp"
  39.                 android:layout_height="fill_parent"
  40.                 android:text="反选" />

  41.             <Button
  42.                 android:id="@+id/bt_deselectall"
  43.                 android:layout_width="80dp"
  44.                 android:layout_height="fill_parent"
  45.                 android:text="取消选择" />
  46.         </LinearLayout>

  47.     </RelativeLayout>

  48. </LinearLayout>
复制代码

开始不显示textview和button的原因是开始指定的listview比较特殊它的layout_height为wrap_content他会填充整个父窗体导致后面的其他子控件显示不了

评分

参与人数 1技术分 +1 收起 理由
杨佳名 + 1 赞一个!

查看全部评分

回复 使用道具 举报
你在listview中加上android:layout_weight="1" 试试
回复 使用道具 举报
这都看不懂 ?怎么学的哦
回复 使用道具 举报
菜鸟一个,完全看不懂啊
回复 使用道具 举报
确认drawable目录下有ok.png或相关文件,选中项目,按F5键刷新一下即可
回复 使用道具 举报 1 0
您需要登录后才可以回帖 登录 | 加入黑马