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 ...
随机推荐
- yii1.1.3主从(多从)、读写分离配置
从新配置main.php片段 代码如下 ----------------------------------------------------------- 'db'=>array( 'con ...
- Java 并发:Executors 和线程池
让我们开始来从入门了解一下 Java 的并发编程. 本文主要介绍如何开始创建线程以及管理线程池,在 Java 语言中,一个最简单的线程如下代码所示: Runnable runnable = new R ...
- http相关概念在iOS中的使用介绍
http://www.cocoachina.com/ios/20160329/15773.html
- self.nsme 和 _name 的问题
.h文件 @interface myclass:NSObject @property(nonatomic,retain)NSArray*MyArray; @end .m文件 @implementati ...
- 关于使用UDP(TCP)跨局域网,NAT穿透的心得
前言: 最近我用java做了一个C/S的类似QQ之类的IM系统(即时通讯系统),遇到了不能跨局域网通讯的问题,经过在网上,和书上查阅了一些资料,了解了一些情况,现在就总结一下我的解决方案 ...
- 10 Ways to Inspire Your Team
Inspire. Just the word itself causes us to pause and think. We may remember our own personal heroes ...
- Xcode插件管理
在使用Xcode的时候,公司同事使用/// 和//TODO 就能打出很多注释信息.虽然他们帮忙给我也装了,但是我却不知道怎么弄的.今天在家无聊,过来自己实践了一把. so easy. 1.我使用的是P ...
- boost::circular_buffer
boost::circular_buffer的push_back分析 circular_buffer为了效率考虑,使用了连续内存块保存元素 使用固定内存,没有隐式或者非期望的内存分配 快速在cir ...
- UVA 10127题目描述
Given any integer 0 ≤ n ≤ 10000 not divisibleby 2 or 5, some multiple of n is a number whichin decim ...
- Java Set操作
Set:无顺序,不包含重复的元素 HashSet:为快速查找设计的Set.存入HashSet的对象必须定义hashCode(). TreeSet: 保存次序的Set, 底层为树结构.使用它可以从Set ...