Demo12SimpleAdapter
/Users/alamps/AndroidStudioProjects/Demo12SimpleAdapter/Demo12SimpleAdapter/src/main/res/layout/data_list.xml
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="42dp">
<TableRow>
<ImageView
android:id="@+id/_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"/>
<TextView
android:id="@+id/_id"
android:textSize="15px"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/_name"
android:textSize="15px"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</TableRow>
</TableLayout>
==========================
/Users/alamps/AndroidStudioProjects/Demo12SimpleAdapter/Demo12SimpleAdapter/src/main/res/layout/activity_main.xml
<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:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<TextView
android:textSize="25px"
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="信息列表INFOLIST" />
<ListView
android:id="@+id/data_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
==============================
package com.example.demo12simpleadapter;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MainActivity extends Activity {
private String data[][]={{"","www.csdn.com"},{"","www.baidu.com"},{"","wwww.alamps.com"},{"","www.iteye.com"},{"","www.google.com"},{"","www.qq.com"}};
private List<Map<String,String>> list = new ArrayList<Map<String,String>>();
private ListView listView;
private SimpleAdapter simpleAdapter=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.listView= (ListView) super.findViewById(R.id.data_list);//mac android studio [alt+return] == eclipse[ctrl+1]
for (int i =;i<this.data.length;i++){
Map<String,String> map = new HashMap<String, String>();
map.put("_id",data[i][]);
map.put("_name",data[i][]);
this.list.add(map);
}
//public SimpleAdapter(android.content.Context context, java.util.List<? extends java.util.Map<java.lang.String,?>> data, int resource, java.lang.String[] from, int[] to) { /* compiled code */ }
this.simpleAdapter = new SimpleAdapter(this,
this.list//数据
,R.layout.data_list,//显示格式
new String[]{"_id","_name"},new int[]{R.id._id,R.id._name});
this.listView.setAdapter(this.simpleAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}

Demo12SimpleAdapter的更多相关文章
- demo14
/Users/alamps/AndroidStudioProjects/Demo12SimpleAdapter/Demo12SimpleAdapter/src/main/res/layout/tabl ...
- Demo13
this.listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void o ...
随机推荐
- 蓝牙Host Controller Interface笔记
1.概述 HCI提供了一个统一的使用蓝牙控制器(BR/EDR Controller,BR/EDR/LE Controller,LE Controller,AMP Controller等)的方法 ...
- nrf51822裸机教程-PPI
Programmable Peripheral Interconnect即可编程外设互联 系统,该模块是51822 提供的一个特性. 目的是为了让51822 的外围模块可以不通过处理器而自动相互作用. ...
- 读书笔记——《图解TCP/IP》(1/4)
读书笔记——<图解TCP/IP>(1/4) 经典摘抄 第一章 网络基础知识 1.独立模式:计算机未连接到网络,各自独立使用的方式. 2.广域网 WAN 局域网 LAN 城域网 MAN 3. ...
- settimeout 传递带有参数的函数
方法一:传递带有参数的function给settimeout,写个函数,该函数返回一个不带参数的函数 <script language="javascript"> fu ...
- MSVC和MinGW组件dll相互调用
http://www.mingw.org/wiki/msvc_and_mingw_dlls MinGW调用VC: The other way is to produce the .a files fo ...
- synchronized原理
http://www.cnblogs.com/YDDMAX/p/5658607.html http://www.cnblogs.com/YDDMAX/p/5658668.html synzhroniz ...
- C语言:十进制进制转换为其他进制(思想:查表法)
// // main.c // Hex conversion // // Created by ma c on 15/7/22. // Copyright (c) 2015年 bjsxt. A ...
- 多台CentOS服务器时间同步(NTP时间同步)(转)
1.用ntpdate从时间服务器更新时间 如果你的linux系统根本没有ntpdate这个命令 yum install ntp 安装完了之后,你不要做什么配置,也不需要,直接测试一下 [root@lo ...
- 微信支付开发(12) 认清微信支付v2和v3
微信支付现在分为v2版和v3版 2014年9月10号之前申请的为v2版,之后申请的为v3版. V2版中的参数有AppIDAppSecret支付专用签名串PaySignKey商户号PartnerID初始 ...
- PISA
http://www.oecd.org/pisa/ 国际学生评估 PISA类测试:一种国际性的科学的评价方法,可强化对考生知识面.综合分析.创新素养方面的考查. 评估内容 第一次PISA评估于2000 ...