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 ...
随机推荐
- jfinal
http://blog.csdn.net/zb0567/article/details/21083021
- 国外it网站收集
1.http://news.com.com/2.http://www.zdnet.com/3.http://www.salon.com/tech/index.html4.http://www.brin ...
- ArcGIS API for Silverlight 点沿着线流动
原文:ArcGIS API for Silverlight 点沿着线流动 概述 前段时间做了一个项目,要求是有一些电力输送线,电力输送线或者石油管道都是有流动方向的,用户想做一个动态效果来模拟电力的输 ...
- Introduction to Project Management(II)
Introduction The purpose of this paper is to gain an understanding of project management and to give ...
- Fiddler-007-修改HTTP请求响应数据
前文简述了如何通过 Fiddler 修改 HTTP请求 的请求参数,详情请参阅:Fiddler-006-修改HTTP请求参数. 在进行 App 测试时,经常需要修改请求参数,以获得不同的显示效果,以查 ...
- SQL Server 未保存.sql文件,还想查看、修改一些建表语句、存储过程等怎么办?
SP_HELPTEXT 表名/视图名/存储过程名:
- iOS 使用Xcode和Instruments调试解决iOS内存泄露(链接转)
http://blog.csdn.net/totogo2010/article/details/8233565
- Python-S13作业-day3-之编辑ha.conf配置文件
Python-S13作业-day3-之编辑ha.conf配置文件 需求: 让用户输入字符串类型的字典,实现对配置文件指定,backend www.oldboy.org下的内容进行 * 查询 * 增加 ...
- Sublime用户如何快速高效开发跨平台App
2015年9月15日,APICloud举办了一周年开源分享会,发布开源插件支持Sublime用户开发跨平台App,APICloud 开源技术负责人周兴海分享了Sublime关于插件方面相关的内容. S ...
- 第十篇 SQL Server安全行级安全
本篇文章是SQL Server安全系列的第十篇,详细内容请参考原文. 不像一些其他industrial-strength数据库服务,SQL Server缺乏一个内置保护个别数据记录的机制,称为行级安全 ...