zoukankan      html  css  js  c++  java
  • 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.hanqi.testapp2.TestActivity7">
    11 
    12     <ListView
    13         android:layout_width="match_parent"
    14         android:layout_height="match_parent"
    15         android:id="@+id/lv_1"></ListView>
    16 
    17 </LinearLayout>
    1 <?xml version="1.0" encoding="utf-8"?>
    2 
    3 
    4 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
    5     android:layout_width="match_parent"
    6     android:layout_height="wrap_content"
    7     android:textSize="20sp"
    8     android:paddingTop="10dp"
    9     android:paddingBottom="10dp" />
     1 package com.hanqi.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 }

  • 相关阅读:
    Python学习——模块的基本知识
    Python学习-软件目录结构规范
    路径追踪的理论与实现:复合重要性采样
    路径追踪的理论与实现:渲染方程
    记一个C++随机数导致的bug
    Gamma矫正的原理和实现
    聊一聊Python的sort函数
    BVH树的构建与遍历
    Cocos动画系统
    Cocos事件分发系统
  • 原文地址:https://www.cnblogs.com/future-zhenzhen/p/5504120.html
Copyright © 2011-2022 走看看