• ListView


    layout代码:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 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"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:orientation="vertical"
        tools:context="com.example.my.myapplication.TestListView">
    
        <ListView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/lv_1">
    
        </ListView>
    </LinearLayout>
    View Code

    Activity代码:

    package com.example.my.myapplication;
    
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;
    
    public class TestListView extends AppCompatActivity {
    
        ListView lv_1;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_test_list_view);
            ListView lv_1=(ListView)findViewById(R.id.lv_1);
    
    
            //1.数据集合
            String [] strings={"A1","A2","A3","A4","A5","A6","A7","A8","A9",
                    "A1","A2","A3","A4","A5","A6","A7","A8","A9"};
            //2.创建Adapter
            ArrayAdapter<String> arrayAdapter=new ArrayAdapter<String>(this,R.layout.array_adapter,strings);
            //3.绑定到ListView
            lv_1.setAdapter(arrayAdapter);
        }
    }
    View Code

    Item布局代码:

    <?xml version="1.0" encoding="utf-8"?>
    
    <TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="20dp"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"/>
    View Code
  • 相关阅读:
    按指定时间段分组统计
    SQL 截取字符
    SQL日期转换
    CentOS7安装rabbitMQ,并实现浏览器访问
    springdata的jpa配置文件application.xml
    在Ubuntu上安装Hive
    在Ubuntu上安装Spark
    在Ubuntu上安装Hbase
    在Ubuntu上安装hadoop-2.7.7
    springboot整合springdatajpa时jar冲突
  • 原文地址:https://www.cnblogs.com/beens/p/5501941.html
Copyright © 2020-2023  润新知