zoukankan      html  css  js  c++  java
  • [Android]ListView学习(一)

    一个简单的LisView

    android默认样式中,item的高度是48sp

    1.新建项目

    2.添加数组字符串数组在res/values/string.xml中

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <string name="hello">Hello World, ListViewActivity!</string>
        <string name="app_name">ListView</string>
        <string-array name="restaurants">
            <item>The Burger Place</item>
            <item>Mick\'s Pizza</item>
            <item>Four Buckets \'o Fruit</item>
            <item>Sam\'s Sushi</item>
        </string-array>
    </resources>

    3.在布局文件中加入ListView 元素并设置 android:entries值为前面添加的数组name

    <?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="fill_parent"
        android:orientation="vertical" >
    
        <ListView
            android:id="@+id/restaurant"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:entries = "@array/restaurants"
            />
    
    </LinearLayout>

    简单的ListView已经完成

  • 相关阅读:
    词频统计
    第二周每周例行报告
    事务管理(ACID)
    Redis
    jar包和war包的区别
    CSS实现Loading加载动画
    如何实现“返回顶部”的页面效果
    PHP页面跳转-常见方法
    局域网络调试方式
    Thinkphp 统计数据库字段总值
  • 原文地址:https://www.cnblogs.com/shocker/p/2466408.html
Copyright © 2011-2022 走看看