zoukankan      html  css  js  c++  java
  • ListView与ArrayAdapter(二)

    ArrayAdapter: 数组适配器,用于简单的文字列表

    activity_main.xml

    <RelativeLayout 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"
        tools:context=".MainActivity" >
    
        <ListView 
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/lv">
        </ListView>
    
    </RelativeLayout>

    Mainactivity.java

    package com.example.arrayadapter;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;
    
    public class MainActivity extends Activity {
    
        private ListView lv;
        private String[] names = { "张一", "张二", "张三", "张四", "张五", "张六", "张七", "张八",
                "张九", "张十", "张十一", "张十二" };
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            lv = (ListView) findViewById(R.id.lv);
            lv.setAdapter(new ArrayAdapter<String>(this,
                    android.R.layout.simple_list_item_1, android.R.id.text1, names));
        }
    
    }
    image
    加油啦!加油鸭,冲鸭!!!
  • 相关阅读:
    node 读取文件
    jQuery全局事件处理函数
    可以发送不同源请求的方式
    ajax 高度封装的函数
    jQuery中AJAX的回调
    jQuery中对AJAX的封装
    ajax 基本的封装
    AJAX 返回数据问题
    ajax 关于响应类型
    动态渲染数据到表格中
  • 原文地址:https://www.cnblogs.com/clarencezzh/p/5229345.html
Copyright © 2011-2022 走看看