今天又初步学习了一下ListView控件,看看效果如下:

LisViewActivity.java源码:

package com.jinhoward.UI_listview;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import android.os.Bundle;

import android.app.Activity;

import android.view.View;

import android.widget.AdapterView;

import android.widget.AdapterView.OnItemClickListener;

import android.widget.ListView;

import android.widget.SimpleAdapter;

import android.widget.Toast;

public class LisViewActivity extends Activity {

ListView listView=null;

Toast toast;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_lis_view);

listView =(ListView)findViewById(R.id.infolistview);

//生成动态数组,加入数据 ,添加的信息有string,也有int类型(图片id),所以用Map

List> list = new ArrayList>();

//一个map相当于listview的一行.

Map map = new HashMap();

map.put("name", "系统信息");

map.put("notes", "系统版本,运营商及其系统信息.");

map.put("img", R.drawable.system);//图片资源的id

list.add(map);

map = new HashMap();

map.put("name", "硬件信息");

map.put("notes", "CPU,硬盘,内存等硬件信息.");

map.put("img", R.drawable.hardware);

list.add(map);

map = new HashMap();

map.put("name", "软件信息");

map.put("notes", "已经安装的软件信息.");

map.put("img", R.drawable.software);

list.add(map);

map = new HashMap();

map.put("name", "运行时信息");

map.put("notes", "运行时的信息.");

map.put("img", R.drawable.running);

list.add(map);

map = new HashMap();

map.put("name", "文件浏览器");

map.put("notes", "文件系统.");

map.put("img", R.drawable.file_explorer);

list.add(map);

//生成适配器的Item和动态数组对应的元素

SimpleAdapter mySimpleAdapter = new SimpleAdapter(this, list, R.layout.item_row,

new String[] { "name", "notes", "img" }, new int[] { R.id.name,

R.id.notes, R.id.img });

//设置适配器

listView.setAdapter(mySimpleAdapter);

//设置监听器

listView.setOnItemClickListener(new OnItemClickListener() {

@Override

public void onItemClick(AdapterView> arg0, View arg1, int arg2,

long arg3) {

// TODO Auto-generated method stub

Toast.makeText(LisViewActivity.this, "您选择了第"+(arg2+1)+"项", Toast.LENGTH_SHORT).show();

}

});

}

}

activity_lis_view.xml源码:

android:id="@+id/LinearLayout1"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:background="#D1EEEE"

>

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:id="@+id/infolistview" />

item_row.xml源码:

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/vw1"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:orientation="horizontal">

android:layout_width="24dp"

android:layout_margin="4dp"

android:layout_height="24dp"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:orientation="vertical">

android:textSize="18sp"

android:textStyle="bold"

android:layout_width="fill_parent"

android:layout_height="wrap_content"/>

android:textSize="12sp"

android:layout_width="fill_parent"

android:layout_height="wrap_content"/>

android listview 开发,android开发之ListView实现相关推荐

  1. Flutter开发之ListView下拉刷新上拉加载更多(35)

    在Flutter开发之ListView组件(21) 文章中,我们了解了ListView组件的基本使用.但是数据比较少,没有涉及分页加载.而实际开发中,下拉刷新和分页加载几乎是所有APP的标配.在iOS ...

  2. Flutter开发之ListView添加HeaderView和FooterView-2(39)

    参考文章:RecyclerView添加HeaderView和FooterView 接着Flutter开发之ListView添加HeaderView和FooterView-1 继续研究. 通过Recyc ...

  3. Flutter开发之ListView使用第三方flutter_refresh加载更多(37)

    在Flutter开发之ListView使用第三方pull_to_refresh加载更多(36) 中我们实现了下拉刷新.上拉分页加载的功能.今天介绍另一个ListView使用第三方flutter_ref ...

  4. Flutter开发之ListView使用第三方pull_to_refresh加载更多(36)

    在Flutter开发之ListView下拉刷新&上拉加载更多(35) 中我们实现了下拉刷新.上拉分页加载的功能.但是使用起来非常不方便,且不满一屏时难以处理. 今天介绍ListView使用第三 ...

  5. android ble 设备扫描程序,Android应用开发Android 7.0 BLE scan 问题:程序无错但扫描不到BLE设备...

    本文将带你了解Android应用开发Android 7.0  BLE scan 问题:程序无错但扫描不到BLE设备,希望本文对大家学Android有所帮助. < 最近在做毕设,需要几周内从头学起 ...

  6. Android游戏开发Android软件开发【教程三十篇】

    Android软件开发之发送短信与系统短信库解析(三十)  New Android软件开发之获取通讯录联系人信息(二十九)  New Android软件开发之PreferenceActivity中的组 ...

  7. android studio socket 失败,Android应用开发Android Studio建立Socket连接失败解决方法

    本文将带你了解Android应用开发Android Studio建立Socket连接失败解决方法,希望本文对大家学Android有所帮助. < Android Studio建立Socket连接失 ...

  8. android落下动画,Android应用开发android 购物车小球掉落动画

    本文将带你了解Android应用开发android 购物车小球掉落动画,希望本文对大家学Android有所帮助. 先贴效果图 对自定义View小红球的绘制 public class BallView ...

  9. android baseactivity,Android应用开发Android通过BaseActivity获取到当前启动的Activity名称...

    本文将带你了解Android应用开发Android通过BaseActivity获取到当前启动的Activity名称,希望本文对大家学Android有所帮助. < 在BaseActivity的on ...

  10. android view 点击变暗,Android应用开发Android ImageView点击变暗效果

    本文将带你了解Android应用开发Android ImageView点击变暗效果,希望本文对大家学Android有所帮助. < 自定义ImageView: 在ImageView中setPres ...

最新文章

  1. 基因组重复序列注释-RepeatMasker安装和使用
  2. leetcode-383-Ransom Note(以空间换时间)
  3. 团队作业1(陈爽、夏江华、李瑞超、甘彩娈、吕乐乐)
  4. initMNN: init numpy failed mnn笔记
  5. 机器学习-数据集类型04
  6. bzoj1935: [Shoi2007]Tree 园丁的烦恼
  7. WebRTC 中的基本音频处理操作
  8. 六元均匀直线阵的各元间距为_实验二 均匀直线阵
  9. vue 将行转换成对象_Vue简化版实现
  10. php 查询键名是否存在,PHP array_key_exists():检测键名是否位于数组中
  11. 软件设计师冲刺笔记(一)
  12. 软件测试经典面试题(一)给你一个水杯如何测试
  13. 万能倍投计算器工具_一周总结上证A股市盈率14.83倍,这是机会还是风险呢?
  14. Django视图系统
  15. POJ 2488 A Knight's Journey
  16. 一分六钱用计算机怎么算,交行信用卡分期付款计算器:5000元分6期手续费
  17. Mac苹果安装Win7时鼠标和键盘没有响应
  18. 高度的思想境界的几个特征
  19. 数据分析 线性回归分析 方差分析表
  20. 安卓手机管理器_iOS苹果手机最好用的三款文件管理器APP

热门文章

  1. php 递归展现城市信息,PHP 递归兑现层级树状展现数据
  2. java对两个表进行排序_Excel工作簿中多个worksheet工作表,如何对工作表进行排序?...
  3. html网页制作图案,巧用CSS滤镜做图案文字-网页设计,HTML/CSS
  4. java merge into_Oracle merge into的使用
  5. HTML 部分常用属性、组成属性|...超链接、路径、锚点、列表、滚动、URL编码、表格、表单、GET和POST
  6. oracle用EXPLAIN PLAN 分析SQL语句
  7. php开发微信图灵机器人
  8. [No0000187]可能是把Java内存区域讲的最清楚的一篇文章
  9. 键盘keydown值表
  10. windows下揪出java程序占用cpu很高的线程