zoukankan      html  css  js  c++  java
  • View(视图)——ListView之ArrayAdapter

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     3     xmlns:tools="http://schemas.android.com/tools"
     4     android:layout_width="match_parent"
     5     android:layout_height="match_parent"
     6     android:paddingBottom="@dimen/activity_vertical_margin"
     7     android:paddingLeft="@dimen/activity_horizontal_margin"
     8     android:paddingRight="@dimen/activity_horizontal_margin"
     9     android:paddingTop="@dimen/activity_vertical_margin"
    10     tools:context="com.example.wang.testapp2.TestActivity7"
    11     android:orientation="vertical">
    12 
    13 
    14     <ListView
    15         android:layout_width="match_parent"
    16         android:layout_height="wrap_content"
    17         android:id="@+id/lv_1" />
    18 </LinearLayout>
    ArrayAdapter.xml
    1 <?xml version="1.0" encoding="utf-8"?>
    2     <TextView xmlns:android="http://schemas.android.com/apk/res/android"
    3     android:layout_width="match_parent"
    4     android:layout_height="wrap_content"
    5     android:textSize="20sp"
    6     android:paddingTop="10dp"
    7     android:paddingBottom="10dp"/>
    arrayadapter.xml
     1 package com.example.wang.testapp2;
     2 
     3 import android.support.v7.app.AppCompatActivity;
     4 import android.os.Bundle;
     5 import android.widget.ArrayAdapter;
     6 import android.widget.ListView;
     7 
     8 public class TestActivity7 extends AppCompatActivity {
     9 
    10     ListView lv_1;
    11 
    12     @Override
    13     protected void onCreate(Bundle savedInstanceState) {
    14         super.onCreate(savedInstanceState);
    15         setContentView(R.layout.activity_test7);
    16 
    17         ListView lv_1=(ListView)findViewById(R.id.lv_1);
    18 
    19         //1.数据集合 Layout
    20         String [] strings={"A1","A2","A3","A4","A5","A6","A7","A8","A9",
    21                 "A1","A2","A3","A4","A5","A6","A7","A8","A9"};
    22 
    23         //2.创建Adapter
    24         ArrayAdapter<String>  arrayAdapter=new ArrayAdapter<String>(this,R.layout.array_adapter,strings);
    25 
    26         //3.绑定到ListView
    27         lv_1.setAdapter(arrayAdapter);
    28 
    29     }
    30 }
    ArrayAdapter.java

  • 相关阅读:
    归并排序,树状数组 两种方法求逆序对
    volley源代码解析(六)--HurlStack与HttpClientStack之争
    what&#39;s new in vc2015
    [ajax 学习笔记] ajax初试
    安卓项目开发实战(1)--首页顶部菜单BAR实现
    eclipse下Tomcat7.0启动奔溃问题
    伸缩--也可用于tabs
    怎样提高团队管理能力8
    mysql查询今天,昨天,近7天,近30天,本月,上一月数据
    SDSoC使用体验
  • 原文地址:https://www.cnblogs.com/arxk/p/5504059.html
Copyright © 2011-2022 走看看