`
guzizai2007
  • 浏览: 354993 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Layout1.5

 
阅读更多

ListView图文列表:  item模板

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" 
    android:gravity="center_horizontal">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/abc_ic_go_search_api_holo_light" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="TextView" />

</LinearLayout>

 

使用SimpleAdapter:

package com.example.android_listview_activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class MainActivity4 extends Activity{
	
	private ListView listView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		listView = (ListView)this.findViewById(R.id.listView1);
		
		Map<String,Object> item1 = new HashMap<String,Object>();
		item1.put("pic", R.drawable.abc_ic_go_search_api_holo_light);
		item1.put("name", "北京");
		
		Map<String,Object> item2 = new HashMap<String,Object>();
		item2.put("pic", R.drawable.abc_ic_go_search_api_holo_light);
		item2.put("name", "上海");
		
		Map<String,Object> item3 = new HashMap<String,Object>();
		item3.put("pic", R.drawable.abc_ic_go_search_api_holo_light);
		item3.put("name", "成都");
		
		Map<String,Object> item4 = new HashMap<String,Object>();
		item4.put("pic", R.drawable.abc_ic_go_search_api_holo_light);
		item4.put("name", "深圳");
		
		List<Map<String,Object>> data = new ArrayList<Map<String,Object>>();
		data.add(item1);
		data.add(item2);
		data.add(item3);
		data.add(item4);
		
		// from和to一一对应  绑定组件
		String[] from = {"pic","name"};
		
		int[] to = {R.id.imageView1,R.id.textView1};
		
		SimpleAdapter simpleAdapter = new SimpleAdapter(this, data, R.layout.source, from, to);
		
		listView.setAdapter(simpleAdapter);
	}
	
}

 

分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

    Programming Windows Presentation Foundation (wpf编程英文文字版)

    Section 1.5. Controls Section 1.6. Data Binding Section 1.7. Dependency Properties Section 1.8. Resources Section 1.9. Styles and Control Templates Section 1.10. Graphics Section 1.11. ...

    PCB 板 layout 中容易被忽视的 12 个细节

    距离建议如下贴片之间器件距离要求:同种器件:≥0.3mm异种器件:≥0.13*h+0.3mm(h为周围近邻元件最大高度差)只能手工贴片的元件之间距离要求:≥1.5mm.上述建议仅供参考,可按照各自公司的PCB工艺设计规范2直插...

    PCB板layout中容易被忽视的12个细节

    贴片元器件之间的间距是工程师在layout时必须注意的一个问题,如果间距太小焊膏印刷和避免焊接连锡难度非常大。距离建议如下: 贴片之间器件距离要求: 同类器件:≥0.3mm 异类器件:≥0.13*h+0.3mm(h为周围近邻...

    Kindle Previewer 1.5 Part 2

    Kindle Previewer makes it easy to preview the layout of a book and make sure its text displays properly for any orientation or font size. This tool is recommended for publishers, eBook conversion ...

    Kindle Previewer 1.5 Part 3

    Kindle Previewer makes it easy to preview the layout of a book and make sure its text displays properly for any orientation or font size. This tool is recommended for publishers, eBook conversion ...

    Kindle Previewer 1.5 Part 1

    Kindle Previewer makes it easy to preview the layout of a book and make sure its text displays properly for any orientation or font size. This tool is recommended for publishers, eBook conversion ...

    Cosmetico v1.5 - Themeforest Responsive eCommerce Wordpress Theme

    Unique Layout Create new skin in just one click by using accent Portfolio Variations- FullScreen, AJAX, PrettyPhoto SEO Ready Premium Revolution Slider Included Header Settings For Pages and Posts- ...

    PhP框架DoitPHP v1.5 MySql版.zip

    (2)、默认的layout由原来的main更改为空(null) 5、Widget Class (1)、去掉display()的第二个参数的支持 (2)、getWidgetId()更名为getWidgetName() (3)、删除template() 6、Module Class (1)、将getModuleId()...

    PHP框架DoitPHP v1.5 SAE版.zip

    (2)、默认的layout由原来的main更改为空(null) 5、Widget Class (1)、去掉display()的第二个参数的支持 (2)、getWidgetId()更名为getWidgetName() (3)、删除template() 6、Module Class (1)、将getModuleId()...

    jquery-easyui-EDT-1.5.5.7z

    layout:修复当鼠标光标快速离开的时候展开的面板不会被折叠的问题; tagbox:修复tagbox框和label标签不在一条直线上的问题。 Improvement(改进) combo:'inputEvents'属性自带'blur'事件处理器; numberbox:'...

    SAP MM customizing

    1.5 ASSIGN PLANT 6 1.6 ASSIGN PURCHASE ORGANIZATION TO PLANT 7 1.7 CREATE PURCHASE GROUP 8 2. BASIC SETUP 10 2.1 DEFINE SCREEN LAYOUT OF MATERIAL MASTER 10 2.2 DEFINE MATERIAL TYPE 11 2.3 SETUP ...

    POLYGON - City Zombies

    - Bellboy Male 01, Biker Male 01, Bio ...- Heaps of awesome content included (see the layout screenshots for more details) - Character setup to work with Mecanim (no animations included in this pack)

    日志内容按日期筛选工具date-filter.zip

    比如 300ms,1.5h,2h45m。使用范例LOG_FILE=/directory/log/xxx.log tail -n 20000 $LOG_FILE | date-filter -layout '2006-01-02 15:04:05' -offset 1 -valid-time 1m | awk -v log_file=$LOG_...

    XMemcached的演示工程

    请问一下 目前 xmemcached 执行的jdk版本是多少?...目前仅兼容到1.5,1.4不兼容;如果需要,你可以自己编译打包一个版本。 从我的角度,不推荐在1.4上使用nio,nio在1.4上的BUG很多。 这个包是我做的演示工程。

    微波设计及应用实践

    已知参数和设计要求: 1) 微带低通滤波器:通带频:1.5GHZ 止带频率:3GHZ 通带波纹:0.8dB 输入输出阻抗:50欧 止带衰减大于40dB ...3) 进行相应的layout图的设计; 4) 进行电磁能量流图的仿真。

    LSSVMlab_v17_R2009b_R2010b.zip

    1.5 and version 1.6, we have tried to change it as little as possible. Here is a summary of the main changes: • The major difference with the previous version is the optimization routine used to find...

    Android代码-Listviews-explorer

    to different parts of the layout. It will evolve as I find new things to tinker with. Some assumptions: I want everything to work under Android 1.5 (Cupcake) and up. This platform still holds ...

    Android代码-一个简洁的基于 RxJava2 的事件总线库

    setContentView(R.layout.activity_main); // 注册 String 类型事件 RxBus.getDefault().subscribe(this, new RxBus.Callback() { @Override public void onEvent(String s) { Log.e("eventTag", s); } });

    Android实现键盘弹出界面上移的实现思路

    基本就是结合layout中ScrollView视图和AndroidManifest.xml中activity中的android:windowSoftInputMode属性配置实现; 2.要了解android:windowSoftInputMode相应的可以配置项: activity主窗口与软键盘的交互模式,...

Global site tag (gtag.js) - Google Analytics